Using ActiveMQ, you can just use the failover transport to automate this: < http://activemq.apache.org/failover-transport-reference.html>.
On 4 January 2017 at 09:34, Paul Mooney <pc.mooney+lo...@gmail.com> wrote: > Hello, > > I am trying to create a logging solution using JMSAppender. The > JMSAppender is working great and is really a great tool to have. > The issue I have is when I restart the JMS broker, the logger fails to > reconnect to the broker. Is there somthing I am missing that can have the > logger reconnect to the JMS broker? > > Technologies: mulesoft ESB, Apache ActiveMQ > > My application log after JMS restart: > > 2017-01-04 09:24:00,949 Log4j2-AsyncLoggerConfig-182 ERROR An exception > occurred processing Appender jmsQueue org.apache.logging.lo > g4j.core.appender.AppenderLoggingException: > javax.jms.IllegalStateException: The Session is closed > at > org.apache.logging.log4j.core.appender.mom.JmsAppender. > append(JmsAppender.java:66) > > at > org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender( > AppenderControl.java:152) > > at > org.apache.logging.log4j.core.config.AppenderControl. > callAppender0(AppenderControl.java:125) > > at > org.apache.logging.log4j.core.config.AppenderControl. > callAppenderPreventRecursion(AppenderControl.java:116) > > at > org.apache.logging.log4j.core.config.AppenderControl. > callAppender(AppenderControl.java:84) > > at > org.apache.logging.log4j.core.config.LoggerConfig. > callAppenders(LoggerConfig.java:390) > > at > org.apache.logging.log4j.core.async.AsyncLoggerConfig.asyncCallAppenders( > AsyncLoggerConfig.java:103) > > at > org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptor$ > Log4jEventWrapperHandler.onEvent(AsyncLoggerConfigDisrupt > or.java:90) > at > org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptor$ > Log4jEventWrapperHandler.onEvent(AsyncLoggerConfigDisrupt > or.java:76) > at > com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128) > at > java.util.concurrent.ThreadPoolExecutor.runWorker( > ThreadPoolExecutor.java:1142) > > at > java.util.concurrent.ThreadPoolExecutor$Worker.run( > ThreadPoolExecutor.java:617) > > at java.lang.Thread.run(Thread.java:745) > Caused by: javax.jms.IllegalStateException: The Session is closed > at > org.apache.activemq.ActiveMQSession.checkClosed(ActiveMQSession.java:771) > at > org.apache.activemq.ActiveMQSession.configureMessage( > ActiveMQSession.java:759) > > at > org.apache.activemq.ActiveMQSession.createTextMessage( > ActiveMQSession.java:440) > > at > org.apache.logging.log4j.core.appender.mom.JmsManager. > createMessage(JmsManager.java:120) > > at > org.apache.logging.log4j.core.appender.mom.JmsAppender. > append(JmsAppender.java:62) > > ... 12 more > > > > My Log4J2.xml properties file: > > <JMS name="jmsQueue" > destinationBindingName="dev.logging" > factoryName="org.apache.activemq.jndi.ActiveMQInitialContextFactory" > factoryBindingName="ConnectionFactory" > providerURL="tcp://<url>:61616?initialReconnectDelay= > 10000,maxReconnectAttempts=10" > userName="log" > password="log"> > <PatternLayout pattern='{"type":"integration", "app":"logtest", > "env":"dev", "date":"%d{ISO8601}", "thread":"[%t]", "loglevel":"%-5p", > "message":"%c - %m"}'/> > </JMS> > > > > Thank you for your time. > Paul > -- Matt Sicker <boa...@gmail.com>