【发布时间】:2019-11-25 15:26:11
【问题描述】:
我正在尝试定义我的“事件处理程序拦截器”, 我按照官方文档here的说明进行操作,但出现以下错误:
org.springframework.beans.factory.BeanCreationException: error when creating the bean with name 'configureEventProcessing' defined in the resource path class [com / prog / boot / config / EventProcessorConfiguration.class]: invalid factory method 'configureEventProcessing': must have an empty non-return type!
我当前的配置调用:
@Configuration
public class EventProcessorConfiguration {
@Bean
public void configureEventProcessing(Configurer configurer) {
configurer.eventProcessing()
.registerTrackingEventProcessor("my-tracking-processor")
.registerHandlerInterceptor("my-tracking-processor",
configuration -> new MyEventHandlerInterceptor());
}
}
我的事件MessageHandlerInterceptor实现:
public class MyEventHandlerInterceptor implements MessageHandlerInterceptor<EventMessage<?>> {
@Override
public Object handle(UnitOfWork<? extends EventMessage<?>> unitOfWork, InterceptorChain interceptorChain)
throws Exception {
EventMessage<?> event = unitOfWork.getMessage();
String userId = Optional.ofNullable(event.getMetaData().get("userId")).map(uId -> (String) uId)
.orElseThrow(Exception::new);
if ("axonUser".equals(userId)) {
return interceptorChain.proceed();
}
return null;
}
}
我做错了什么?
谢谢!
【问题讨论】:
标签: java spring eventhandler axon