private void handleSagaMessage(final Object invokeParam) throws InvocationTargetException, IllegalAccessException {
Collection<SagaInstanceDescription> sagaDescriptions = sagaFactory.create(invokeParam);
if (sagaDescriptions.isEmpty()) {
LOG.warn("No saga found to handle message. {}", invokeParam);
} else {
CurrentExecutionContext context = contextProvider.get();
context.setMessage(invokeParam);
for (SagaInstanceDescription sagaDescription : sagaDescriptions) {
Saga saga = sagaDescription.getSaga();
context.setSaga(saga);
setSagaExecutionContext(saga, context);
invoker.invoke(saga, invokeParam);
updateStateStorage(sagaDescription);
if (context.dispatchingStopped()) {
LOG.debug("Handler dispatching stopped after invoking saga {}.", sagaDescription.getSaga().getClass().getSimpleName());
break;
}
}
}