Skip to content

Commit

Permalink
Adjust AbstractSagaManager to not provide the SagaDescriptor generic
Browse files Browse the repository at this point in the history
-Adjust AbstractSagaManager to not provide the SagaDescriptor generic
-Adjust the send() function accordingly

#220
  • Loading branch information
smcvb committed Jun 11, 2018
1 parent 1f912e9 commit f7ad350
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @author Allard Buijze * @author Allard Buijze
* @since 0.7 * @since 0.7
*/ */
public abstract class AbstractSagaManager<T> implements EventHandlerInvoker, ScopeAware<SagaDescriptor> { public abstract class AbstractSagaManager<T> implements EventHandlerInvoker, ScopeAware {


private final SagaRepository<T> sagaRepository; private final SagaRepository<T> sagaRepository;
private final Class<T> sagaType; private final Class<T> sagaType;
Expand Down Expand Up @@ -193,17 +193,19 @@ public void performReset() {
} }


@Override @Override
public void send(Message<?> message, SagaDescriptor sagaDescription) throws Exception { public void send(Message<?> message, ScopeDescriptor scopeDescription) throws Exception {
if (!(message instanceof EventMessage)) { if (!(message instanceof EventMessage)) {
String exceptionMessage = String.format( String exceptionMessage = String.format(
"Something else than an EventMessage was scheduled for Saga of type [%s] and id [%s], whilst Sagas can only handle EventMessages.", "Something else than an EventMessage was scheduled for Saga of type [%s], whilst Sagas can only handle EventMessages.",
sagaDescription.getType(), getSagaType()
sagaDescription.getIdentifier()
); );
throw new IllegalArgumentException(exceptionMessage); throw new IllegalArgumentException(exceptionMessage);
} }
sagaRepository.load(sagaDescription.getIdentifier().toString())
.handle((EventMessage) message); if (scopeDescription instanceof SagaDescriptor) {
sagaRepository.load(((SagaDescriptor) scopeDescription).getIdentifier().toString())
.handle((EventMessage) message);
}
} }


@Override @Override
Expand Down

0 comments on commit f7ad350

Please sign in to comment.