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 |
DeserializationPostInitialisable.Implementation| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_STORE_PREFIX |
static Event[] |
EMPTY_EVENTS_ARRAY |
static String |
MULE_ARRIVAL_ORDER_PROPERTY |
| Constructor and Description |
|---|
EventGroup(Object groupId,
MuleContext muleContext) |
EventGroup(Object groupId,
MuleContext muleContext,
Optional<Integer> expectedSize,
String storePrefix) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEvent(Event 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.
|
Optional<Integer> |
expectedSize()
Returns the number of events that this EventGroup is expecting before correlation can proceed.
|
long |
getCreated()
Return the creation timestamp of the current group in milliseconds.
|
Object |
getGroupId()
Returns an identifier for this EventGroup.
|
protected MuleSession |
getMergedSession(Event[] events) |
Event |
getMessageCollectionEvent() |
int |
hashCode()
The hashCode of an EventGroup is derived from the object returned by
getGroupId(). |
void |
initAfterDeserialisation(MuleContext context) |
void |
initEventsStore(PartitionableObjectStore<Event> events) |
boolean |
isInitialised() |
Iterator<Event> |
iterator()
Returns an iterator over a snapshot copy of this group's collected events sorted by their arrival time.
|
Iterator<Event> |
iterator(boolean sortByArrival)
Returns an iterator over a snapshot copy of this group's collected events., optionally sorted by arrival order.
|
int |
size()
Returns the number of events collected so far.
|
Event[] |
toArray()
Returns a snapshot of collected events in this group sorted by their arrival time.
|
Event[] |
toArray(boolean sortByArrival)
Returns a snapshot of collected events in this group, optionally sorted by their arrival time.
|
String |
toString() |
public static final Event[] 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, Optional<Integer> 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 ObjectObject.equals(Object)public int hashCode()
getGroupId().hashCode in class ObjectObject.hashCode()public Object getGroupId()
Comparable e.g. a UUID.public Iterator<Event> iterator() throws org.mule.runtime.api.store.ObjectStoreException
#removeEvent(Event). 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.Events.org.mule.runtime.api.store.ObjectStoreExceptionpublic Iterator<Event> iterator(boolean sortByArrival) throws org.mule.runtime.api.store.ObjectStoreException
#removeEvent(Event). 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.Events.org.mule.runtime.api.store.ObjectStoreExceptionpublic Event[] toArray() throws org.mule.runtime.api.store.ObjectStoreException
Events.org.mule.runtime.api.store.ObjectStoreExceptionpublic Event[] toArray(boolean sortByArrival) throws org.mule.runtime.api.store.ObjectStoreException
Events.org.mule.runtime.api.store.ObjectStoreExceptionpublic void addEvent(Event event) throws org.mule.runtime.api.store.ObjectStoreException
event - the event to addorg.mule.runtime.api.store.ObjectStoreExceptionpublic long getCreated()
public int size()
public Optional<Integer> expectedSize()
public void clear()
throws org.mule.runtime.api.store.ObjectStoreException
org.mule.runtime.api.store.ObjectStoreExceptionpublic Event getMessageCollectionEvent()
protected MuleSession getMergedSession(Event[] events) throws org.mule.runtime.api.store.ObjectStoreException
org.mule.runtime.api.store.ObjectStoreExceptionpublic void initAfterDeserialisation(MuleContext context) throws org.mule.runtime.api.exception.MuleException
org.mule.runtime.api.exception.MuleExceptionpublic void initEventsStore(PartitionableObjectStore<Event> events) throws org.mule.runtime.api.store.ObjectStoreException
org.mule.runtime.api.store.ObjectStoreExceptionpublic boolean isInitialised()
Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.