samedi 28 février 2015

(Spring) Filtering multicasters based on event type

I have a custom event, which I call LoginEvent (which extends ApplicationEvent) defined. I have defined a few listeners which are listening to this event. I have figured our how to make the event listeners asynchronous (by changing the taskExecutor within eventMulticaster). This is how I have made my events to be thrown in an asynchronous manner.



<bean id="applicationEventMulticaster" class="org.springframework.context.event.SimpleApplicationEventMulticaster">
<property name="taskExecutor" > <bean class="org.springframework.core.task.SimpleAsyncTaskExecutor"
/> </property> </bean>


But from what I understand, this is going to force ALL of my custom events go asynchronous. I don't want to do that if I can have a way to chose different taskExecutors for different types of events (ir, categorize my Events as Sync ans async). How can I achieve that?


Aucun commentaire:

Enregistrer un commentaire