Package org.mule.routing

Examples of org.mule.routing.EventGroup


     * Creates a new EventGroup that will expect the number of events as returned by
     * {@link MuleMessage#getCorrelationGroupSize()}.
     */
    public EventGroup createEventGroup(MuleEvent event, Object groupId)
    {
        return new EventGroup(groupId, muleContext, event.getMessage().getCorrelationGroupSize(),
            persistantStores, storePrefix);
    }
View Full Code Here


            {
                throw new RoutingException(event, timeoutMessageProcessor, e);
            }

            // check for an existing group first
            EventGroup group;
            try
            {
                group = this.getEventGroup(groupId);
            }
            catch (ObjectStoreException e)
            {
                throw new RoutingException(event, timeoutMessageProcessor, e);
            }

            // does the group exist?
            if (group == null)
            {
                // ..apparently not, so create a new one & add it
                try
                {
                    group = this.addEventGroup(callback.createEventGroup(event, groupId));
                }
                catch (ObjectStoreException e)
                {
                    throw new RoutingException(event, timeoutMessageProcessor, e);
                }
            }

            // ensure that only one thread at a time evaluates this EventGroup
            synchronized (groupsLock)
            {
                if (logger.isDebugEnabled())
                {
                    logger.debug("Adding event to aggregator group: " + groupId);
                }

                // add the incoming event to the group
                try
                {
                    group.addEvent(event);
                }
                catch (ObjectStoreException e)
                {
                    throw new RoutingException(event, timeoutMessageProcessor, e);
                }

                // check to see if the event group is ready to be aggregated
                if (callback.shouldAggregateEvents(group))
                {
                    // create the response event
                    MuleEvent returnEvent = callback.aggregateEvents(group);
                    returnEvent.getMessage().setCorrelationId(groupId);
                    String rootId = group.getCommonRootId();
                    if (rootId != null)
                    {
                        returnEvent.getMessage().setMessageRootId(rootId);
                    }

                    // remove the eventGroup as no further message will be received
                    // for this group once we aggregate
                    try
                    {
                        this.removeEventGroup(group);
                        group.clear();
                    }
                    catch (ObjectStoreException e)
                    {
                        throw new RoutingException(event, timeoutMessageProcessor, e);
                    }
View Full Code Here

    protected EventGroup getEventGroup(Serializable groupId) throws ObjectStoreException
    {
        try
        {
            EventGroup eventGroup = eventGroups.retrieve(groupId);
            if (!eventGroup.isInitialised())
            {
                try
                {
                    DeserializationPostInitialisable.Implementation.init(eventGroup, muleContext);
                }
View Full Code Here

            List<EventGroup> expired = new ArrayList<EventGroup>(1);
            try
            {
                for (Serializable o : eventGroups.allKeys())
                {
                    EventGroup group = getEventGroup(o);
                    if (group.getCreated() + getTimeout() < System.currentTimeMillis())
                    {
                        expired.add(group);
                    }
                }
            }
            catch (ObjectStoreException e)
            {
                logger.warn("expiry failed dues to ObjectStoreException " + e);
            }
            if (expired.size() > 0)
            {
                for (Object anExpired : expired)
                {
                    final EventGroup group = (EventGroup) anExpired;
                    ExecutionTemplate<MuleEvent> executionTemplate = ErrorHandlingExecutionTemplate.createErrorHandlingExecutionTemplate(muleContext, flowConstruct.getExceptionListener());
                    try
                    {
                        executionTemplate.execute(new ExecutionCallback<MuleEvent>()
                        {
View Full Code Here

TOP

Related Classes of org.mule.routing.EventGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.