I am writing a small demonstration app using the Axon event bus
(1.1.2). It is a Spring 3 app.
For some reason my handler is not subscribing to the bus. Any ideas?
Thanks. Eric
applicationContext:
. . .
<axon:event-bus id="eventBus"/>
<bean
class="org.axonframework.eventhandling.annotation.AnnotationEventListenerBeanPostProcessor">
<property name="eventBus" ref="eventBus"/>
<property name="executor" ref="taskExecutor"/>
</bean>
<bean id="taskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="2"/>
<property name="maxPoolSize" value="5"/>
<property name="waitForTasksToCompleteOnShutdown"
value="true"/>
</bean>
. . .
handler:
@AsynchronousEventListener
public class ExampleHandler {
@EventHandler
public void onExampleEvent(ExampleEvent event) {
try {
FileWriter fw = new FileWriter("log.txt", true);
fw.write(event.getText());
fw.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
event generator:
@Autowired
SimpleEventBus eventBus;
. . .
public void sendExampleEvent(String color, String shape) {
ExampleEvent event = new ExampleEvent();
event.setText(color + " " + shape);
eventBus.publish(event);
}