使用Java和Spring3.x,我正在编写示例,使用apache路由来生成和使用基于Spring的事件。我很惊讶谷歌搜索没有返回任何有意义的结果。我的意思是,不是一个使用apache camel使用spring事件组件的例子。
下面是我的事件对象/publisher/listener可以帮助我使用apache - event :// DSL来转换它。
任何帮助都是非常感谢的。
我的自定义事件类
public class CustomSpringEvent extends ApplicationEvent {
private String message;
public CustomSpringEvent(Object source, String message) {
super(source);
this.message = message;
}
public String getMessage() {
return message;
}
}出版商
@Component
public class CustomSpringEventPublisher {
@Autowired
private ApplicationEventPublisher applicationEventPublisher;
public void publishCustomEvent(final String message) {
System.out.println("Publishing custom event. ");
CustomSpringEvent customSpringEvent = new CustomSpringEvent(this, message);
applicationEventPublisher.publishEvent(customSpringEvent);
}
}听者
@Component
public class CustomSpringEventListener {
@EventListener
public void onApplicationEvent(CustomSpringEvent event) {
System.out.println("Received spring custom event - " + event.getMessage());
}
}春季事件
https://www.baeldung.com/spring-events
Apache骆驼春季事件组件
https://camel.apache.org/components/3.4.x/spring-event-component.html
发布于 2021-09-27 14:57:33
您只需创建一个从spring-event:foo开始的骆驼路线,其中foo可以是任何东西。
https://stackoverflow.com/questions/69274238
复制相似问题