java - Trigger an event with ApplicationEventPublisher from a RabbitMQ listener class -
in webapp (java 8, spring 4) have rabbit listener class, , need trigger event when handler method finish execution.
when put code inside listener class nullpointerexception thrown, if put in @controller or @service running in "main" thread works fine. believe context or that.
public class mylistener { @autowired private applicationeventpublisher publisher; ... private void sendnotification() { ... publisher.publishevent(notificationevent); } } "publisher" object not null , "notificationevent" not null, (it not basic error).
i debugging spring-context.jar sources, , exception thrown inside reflection class called "method",
// java.lang.reflect.method, line 483 return ma.invoke(obj, args); as said if put code in controller or service running in "main thread" ok, when put in rabbit class listener error.
<bean id="mylistener" class="com.example.mylistener /> <rabbit:listener-container connection-factory="connectionfactory" error-handler="queueerrorhandler" > <rabbit:listener ref="mylistener" method="handlemethod" queue-names="myqueue" /> </rabbit:listener-container> i believe execution context, don't know can be
Comments
Post a Comment