java - Unable to restart a DefaultMessageListenerContainer -
we're using spring 4.3.1, , getting messages queue using following bean:
@bean(name="listenercontainer") public sprmessagelistenercontainer listenercontainer() throws jmsexception, sqlexception { sprmessagelistenercontainer listenercontainer = new sprmessagelistenercontainer(); listenercontainer.setconnectionfactory((connectionfactory) connectionfactory()); listenercontainer.setmessagelistener(messagelistener()); listenercontainer.setsessiontransacted(true); listenercontainer.setcachelevel(0); listenercontainer.setmaxconcurrentconsumers(3); listenercontainer.setdestinationname("ourqueue"); // (april 2017): provide possibility manually stop/start listner container > autostart needs set false, otherwise can stop container, not restart anymore // see: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/jms/listener/abstractjmslisteningcontainer.html#setautostartup-boolean- listenercontainer.settransactionmanager(jmstransactionmanager()); listenercontainer.setautostartup(false); listenercontainer.start(); assert.istrue(listenercontainer.isrunning()); return listenercontainer; } @bean(name="connectionfactory") public connectionfactory connectionfactory() throws jmsexception, sqlexception { return aqjmsfactory.getconnectionfactory(datasourceconfig.gpdatasourceadapter()); } private jmstransactionmanager jmstransactionmanager() throws jmsexception, sqlexception { jmstransactionmanager transactionmanager = new jmstransactionmanager(); transactionmanager.setconnectionfactory(connectionfactory()); return transactionmanager; }
sprmessagelistenercontainer is:
public class sprmessagelistenercontainer extends defaultmessagelistenercontainer { @override protected messageconsumer createconsumer(session session, destination destination) throws jmsexception { return ((aqjmssession) session).createconsumer(destination, null, new sproradatafactory(), null, false); } @override protected void doshutdown() throws jmsexception { logger.info("shutting done."); }
}
in our application, correctly reference our listenercontainer bean. when application start, listener correctly started, , see message getting processed.
in our code, do:
listenercontainer.shutdown();
then, no message processed anymore > expected.
but, further in our code, do:
listenercontainer.start();
we expect messages processed again, it's not case, nothing happen (we don't exception and/or error).
is wrongly configured in our bean? missing in order manually stop/start our container?
well ... answering myself ... missing call afterpropertiesset() method.
Comments
Post a Comment