use of org.mule.runtime.core.api.message.GroupCorrelation.NOT_SET in project mule by mulesoft.
the class EventCorrelator method handleGroupExpiry.
protected void handleGroupExpiry(EventGroup group) throws MuleException {
try {
removeEventGroup(group);
} catch (ObjectStoreException e) {
throw new DefaultMuleException(e);
}
if (isFailOnTimeout()) {
CoreEvent messageCollectionEvent = group.getMessageCollectionEvent();
notificationFirer.dispatch(new RoutingNotification(messageCollectionEvent.getMessage(), null, CORRELATION_TIMEOUT));
try {
group.clear();
} catch (ObjectStoreException e) {
logger.warn("Failed to clear group with id " + group.getGroupId() + " since underlying ObjectStore threw Exception:" + e.getMessage());
}
throw new CorrelationTimeoutException(correlationTimedOut(group.getGroupId()));
} else {
if (logger.isDebugEnabled()) {
logger.debug(MessageFormat.format("Aggregator expired, but ''failOnTimeOut'' is false. Forwarding {0} events out of {1} " + "total for group ID: {2}", group.size(), group.expectedSize().map(v -> v.toString()).orElse(NOT_SET), group.getGroupId()));
}
try {
if (!(group.getCreated() + DAYS.toMillis(1) < currentTimeMillis())) {
CoreEvent newEvent = CoreEvent.builder(callback.aggregateEvents(group)).build();
group.clear();
if (!correlatorStore.contains((String) group.getGroupId(), getExpiredAndDispatchedPartitionKey())) {
// returned?
if (timeoutMessageProcessor != null) {
processToApply(newEvent, timeoutMessageProcessor, false, empty());
} else {
throw new MessagingException(createStaticMessage(MessageFormat.format("Group {0} timed out, but no timeout message processor was " + "configured.", group.getGroupId())), newEvent);
}
correlatorStore.store((String) group.getGroupId(), group.getCreated(), getExpiredAndDispatchedPartitionKey());
} else {
logger.warn(MessageFormat.format("Discarding group {0}", group.getGroupId()));
}
}
} catch (MessagingException me) {
throw me;
} catch (Exception e) {
throw new MessagingException(group.getMessageCollectionEvent(), e);
}
}
}
Aggregations