java - I need to check the status of the activemq broker before the messages sent -
actually usecase need handle broker not available situation. need know status of broker before send messsages? tried below sendtimeout property, still not success.
<bean primary="true" id="jmsconnectionfactory" class="org.apache.activemq.activemqconnectionfactory"> <property name="brokerurl" value="failover:(tcp://localhost:61616)" /> <property name="useasyncsend" value="true" /> <property name="watchtopicadvisories" value="false" /> <property name="sendtimeout" value="2000" /> </bean>
connection conn = null; try { conn = connectionfactory.createconnection(); jmstemplate.send(...); } catch (exception e) { ... } { if (conn != null) { conn.close(); } }
or can send within try/catch.
also, it's better wrap activemqconnectionfactory
in cachingconnectionfactory
avoid opening connection each send.
wiki
Comments
Post a Comment