Retry to establish a JMS connection while ActiveMQ broker is not available -


here scenario. have few activemq (jboss-amq) producers , consumers installed services. in server restart, best practice of handling such situation producer or consumer service starts before activemq broker service. in case producer/client cannot establish connection , starts hang on after broker service starts.

here's code snippet of connection creation:

try {             connection = connectionfactory.createconnection();             connection.start();             logger.info(started_connection_with_the_destination + destinationname);             session = createsession();             destination = session.createqueue(destinationname);             logger.info(created_queue_in_destination + destinationname);             if (isimageprocagent) {                 consumer = createconsumer();                 logger.info(consumer_has_been_initialized);             } else {                 producer = session.createproducer(destination);                 logger.info(producer_has_been_initialize);             }         } catch (messagingexception e) {             logger.error(e);         } catch (jmsexception e) {             logger.error(e);         } 

i'm new jms appreciate support.

this can achieved configuring failover this document explains. according code snippet, change required it:

destination = session.createqueue("failover:"+destinationname); producer = session.createproducer("failover:"+destination); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -