0

I have a sample app demo working with:

  • Spring Framework 4.2.5
  • ActiveMQ 5.13.3

I have the following:

@Bean(name="connectionFactory")
public CachingConnectionFactory cachingConnectionFactory(ActiveMQConnectionFactory selectedActiveMQConnectionFactory) throws JMSException{
    CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
    cachingConnectionFactory.setClientId("ManolitoActiveMQ");
    cachingConnectionFactory.setTargetConnectionFactory(selectedActiveMQConnectionFactory);
    cachingConnectionFactory.setSessionCacheSize(10);
    cachingConnectionFactory.createConnection().start();
    return cachingConnectionFactory;
}

When I use the cachingConnectionFactory.createConnection().start(); line I can see that when my app starts it shows:

3370 [main] INFO o.s.j.c.CachingConnectionFactory - Established shared JMS Connection: ActiveMQConnection {id=ID:sometext,clientId=ManolitoActiveMQ,started=false}

Has sense expect that message when the app starts and read Established shared JMS Connection but why shows started=false? I think should be true.

If I comment cachingConnectionFactory.createConnection().start(); and start the app, the message shown above does not appear, ok, it is expected. But later through JMX when I start to send messages, I can see again

3370 [main] INFO o.s.j.c.CachingConnectionFactory - Established shared JMS Connection: ActiveMQConnection {id=ID:sometext,clientId=ManolitoActiveMQ,started=false}

Ok it is expected, but again started=false appears

It is confuse in some point because the cachingConnectionFactory.createConnection().start() line ends with start() for the Connection

  1. Therefore why practically always appears started=false?
  2. When or how that started attribute would appear with true?
Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158

1 Answers1

2

Notice that the started=false is in the toString() of the connection - it has nothing to do with the connection factory; it relates to the connection just created.

logger.info("Established shared JMS Connection: " + this.connection);

The connection itself will be started later if needed.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179