如in the docs所述,我正在将Saga对象与特定的事件属性相关联。从起始的saga事件处理程序方法中调用SagaLifecycle.associateWith
方法:
@StartSaga
@SagaEventHandler(associationProperty = "orderId")
public void handle(OrderCreatedEvent event) {
// ...
SagaLifecycle.associateWith("shipmentId", shipmentId); //fails
// ...
}
但是,该调用失败,因为没有作用域处于活动状态。我在文档中没有看到任何指示可以激活示波器的说明。有线索吗?
java.lang.IllegalStateException: Cannot request current Scope if none is active
at org.axonframework.messaging.Scope.getCurrentScope(Scope.java:57) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.modelling.saga.SagaLifecycle.getInstance(SagaLifecycle.java:118) ~[axon-modelling-4.0.jar:4.0]
at org.axonframework.modelling.saga.SagaLifecycle.associateWith(SagaLifecycle.java:57) ~[axon-modelling-4.0.jar:4.0]
at org.axonframework.modelling.saga.SagaLifecycle.associateWith(SagaLifecycle.java:35) ~[axon-modelling-4.0.jar:4.0]
at com.example.sagas.OrderSaga.handle(OrderSaga.java:56) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
at org.axonframework.messaging.annotation.AnnotatedMessageHandlingMember.handle(AnnotatedMessageHandlingMember.java:127) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.modelling.saga.SagaMethodMessageHandlingMember.handle(SagaMethodMessageHandlingMember.java:80) ~[axon-modelling-4.0.jar:4.0]
at org.axonframework.eventhandling.AnnotationEventHandlerAdapter.handle(AnnotationEventHandlerAdapter.java:81) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.SimpleEventHandlerInvoker.handle(SimpleEventHandlerInvoker.java:111) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.MultiEventHandlerInvoker.handle(MultiEventHandlerInvoker.java:79) [axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.AbstractEventProcessor.lambda$null$1(AbstractEventProcessor.java:141) [axon-messaging-4.0.jar:4.0]
at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:57) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.messaging.interceptors.CorrelationDataInterceptor.handle(CorrelationDataInterceptor.java:65) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.TrackingEventProcessor.lambda$new$1(TrackingEventProcessor.java:132) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.messaging.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:55) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.AbstractEventProcessor.lambda$processInUnitOfWork$2(AbstractEventProcessor.java:148) [axon-messaging-4.0.jar:4.0]
at org.axonframework.messaging.unitofwork.BatchingUnitOfWork.executeWithResult(BatchingUnitOfWork.java:86) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.AbstractEventProcessor.processInUnitOfWork(AbstractEventProcessor.java:136) [axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.TrackingEventProcessor.processBatch(TrackingEventProcessor.java:258) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.TrackingEventProcessor.processingLoop(TrackingEventProcessor.java:181) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.TrackingEventProcessor$TrackingSegmentWorker.run(TrackingEventProcessor.java:661) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.TrackingEventProcessor$WorkerLauncher.run(TrackingEventProcessor.java:771) ~[axon-messaging-4.0.jar:4.0]
at org.axonframework.eventhandling.TrackingEventProcessor$CountingRunnable.run(TrackingEventProcessor.java:588) ~[axon-messaging-4.0.jar:4.0]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_191]
答案 0 :(得分:2)
在春天,传奇需要用@Saga
注释。