public class EventGroup extends Object implements Comparable<EventGroup>, Serializable, DeserializationPostInitialisable
EventGroup
is a holder over events grouped by a common group Id. This
can be used by components such as routers to managed related events.Modifier and Type | Class and Description |
---|---|
class |
EventGroup.ArrivalOrderEventComparator |
class |
EventGroup.ArrivalOrderMessageComparator |
DeserializationPostInitialisable.Implementation
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_STORE_PREFIX |
static MuleEvent[] |
EMPTY_EVENTS_ARRAY |
static String |
MULE_ARRIVAL_ORDER_PROPERTY |
Constructor and Description |
---|
EventGroup(Object groupId,
MuleContext muleContext) |
EventGroup(Object groupId,
MuleContext muleContext,
int expectedSize,
String storePrefix) |
Modifier and Type | Method and Description |
---|---|
void |
addEvent(MuleEvent event)
Add the given event to this group.
|
void |
clear()
Removes all events from this group.
|
int |
compareTo(EventGroup other)
Compare this EventGroup to another one.
|
boolean |
equals(Object obj)
Compares two EventGroups for equality.
|
int |
expectedSize()
Returns the number of events that this EventGroup is expecting before
correlation can proceed.
|
String |
getCommonRootId() |
long |
getCreated()
Return the creation timestamp of the current group in milliseconds.
|
Object |
getGroupId()
Returns an identifier for this EventGroup.
|
protected MuleSession |
getMergedSession() |
MuleEvent |
getMessageCollectionEvent() |
int |
hashCode()
The hashCode of an EventGroup is derived from the object returned by
getGroupId() . |
void |
initAfterDeserialisation(MuleContext context) |
void |
initEventsStore(PartitionableObjectStore<MuleEvent> events) |
boolean |
isInitialised() |
Iterator<MuleEvent> |
iterator()
Returns an iterator over a snapshot copy of this group's collected events
sorted by their arrival time.
|
Iterator<MuleEvent> |
iterator(boolean sortByArrival)
Returns an iterator over a snapshot copy of this group's collected events.,
optionally sorted by arrival order.
|
void |
removeEvent(MuleEvent event)
Remove the given event from the group.
|
int |
size()
Returns the number of events collected so far.
|
MuleEvent[] |
toArray()
Returns a snapshot of collected events in this group sorted by their arrival time.
|
MuleEvent[] |
toArray(boolean sortByArrival)
Returns a snapshot of collected events in this group, optionally sorted by their arrival time.
|
MuleMessageCollection |
toMessageCollection() |
MuleMessageCollection |
toMessageCollection(boolean sortByArrival) |
String |
toString() |
public static final MuleEvent[] EMPTY_EVENTS_ARRAY
public static final String MULE_ARRIVAL_ORDER_PROPERTY
public static final String DEFAULT_STORE_PREFIX
public EventGroup(Object groupId, MuleContext muleContext)
public EventGroup(Object groupId, MuleContext muleContext, int expectedSize, String storePrefix)
public int compareTo(EventGroup other)
Comparable
, they are used for the comparison;
otherwise - since the id can be any object - the group creation time stamp is
used as fallback. Older groups are considered "smaller".compareTo
in interface Comparable<EventGroup>
Comparable.compareTo(java.lang.Object)
public boolean equals(Object obj)
getGroupId()
) are equal.equals
in class Object
Object.equals(Object)
public int hashCode()
getGroupId()
.hashCode
in class Object
Object.hashCode()
public Object getGroupId()
Comparable
e.g. a UUID.public Iterator<MuleEvent> iterator() throws ObjectStoreException
removeEvent(MuleEvent)
. If you need to do so atomically in order to
prevent e.g. concurrent reception/aggregation of the group during iteration,
wrap the iteration in a synchronized block on the group instance.MuleEvent
s.ObjectStoreException
public Iterator<MuleEvent> iterator(boolean sortByArrival) throws ObjectStoreException
removeEvent(MuleEvent)
. If you need to do so atomically in order to
prevent e.g. concurrent reception/aggregation of the group during iteration,
wrap the iteration in a synchronized block on the group instance.MuleEvent
s.ObjectStoreException
public MuleEvent[] toArray() throws ObjectStoreException
MuleEvent
s.ObjectStoreException
public MuleEvent[] toArray(boolean sortByArrival) throws ObjectStoreException
MuleEvent
s.ObjectStoreException
public void addEvent(MuleEvent event) throws ObjectStoreException
event
- the event to addObjectStoreException
public void removeEvent(MuleEvent event) throws ObjectStoreException
event
- the evnt to removeObjectStoreException
public long getCreated()
public int size()
public int expectedSize()
public void clear() throws ObjectStoreException
ObjectStoreException
public MuleMessageCollection toMessageCollection() throws ObjectStoreException
ObjectStoreException
public MuleMessageCollection toMessageCollection(boolean sortByArrival) throws ObjectStoreException
ObjectStoreException
public String getCommonRootId()
public MuleEvent getMessageCollectionEvent()
protected MuleSession getMergedSession() throws ObjectStoreException
ObjectStoreException
public void initAfterDeserialisation(MuleContext context) throws MuleException
MuleException
public void initEventsStore(PartitionableObjectStore<MuleEvent> events) throws ObjectStoreException
ObjectStoreException
public boolean isInitialised()
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.