Uploaded image for project: 'ActiveMQ'
  1. ActiveMQ
  2. AMQ-8102

Broker is automatically restarted during shutdown when using the vm transport

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: In Progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Broker
    • Labels:

      Description

      AMQ is embedded within a spring application. The only transport that is configured is the VM transport

       

      <amq:broker useJmx="false" persistent="true" dataDirectory="var/jms">
       <amq:transportConnectors>
       <amq:transportConnector uri="vm://localhost" />
       </amq:transportConnectors>
      </amq:broker>
      <bean
      class="org.springframework.jms.listener.DefaultMessageListenerContainer
      " >
       <property name="connectionFactory" ref="connectionFactory"/>
       <property name="destination" ref="someTopic"/>
       <property name="sessionTransacted" value="true" />
       <property name="pubSubDomain" value="true"/> 
       <property name="subscriptionDurable" value="true" />
       <property name="clientId" value="clientid" />
       <property name="durableSubscriptionName" value="somename" />
      </bean>
      
      

       

      During shutdown, a new broker instance is created with default values, thereby ignoring the configured values like dataDirectory etc. This then resuls in the creation of the default dataDirectory with a new KahaDB

      The cause:

      The DefaultMessageListenerContainer detects that the connection to the broker fails (because the broker is shutdown).

      The DefaultMessageListenerContainer#recoverAfterListenerSetupFailure method then tries to recover from the connection failure.
      This then results in the automatic creation of a new broker instance because the create option of the VM transport is set to true by default:

      "create ... If the broker should be created on demand if it does not
      already exist."

      From https://activemq.apache.org/vm-transport-reference

      A workaround is to set the create value for the connection URI to false:

      <amq:connectionFactory id="amqConnectionFactory" brokerURL="vm://localhost?create=false">
      

      Stacktrace of the shutdown process:

      [exec] 14 Dec 2020 15:41:32 | DEBUG ID:martijn-laptop-46343-
      1607956885604-4:1:1 Transaction Commit
      :null (org.apache.activemq.ActiveMQSession)
      org.springframework.jms.listener.DefaultMessageListenerContainer#0-1
      [exec] 14 Dec 2020 15:41:32 | DEBUG Publishing: vm://localhost for
      broker transport URI:
      vm://localhost (org.apache.activemq.broker.TransportConnector)
      [ActiveMQ BrokerService[localhost] Task-2]
      [exec] 14 Dec 2020 15:41:32 | DEBUG Publishing: vm://localhost for
      broker transport URI:
      vm://localhost (org.apache.activemq.broker.TransportConnector)
      [ActiveMQ BrokerService[localhost] Task-2]
      [exec] 14 Dec 2020 15:41:32 | DEBUG Connection Stopped:
      vm://localhost#0 (org.apache.activemq.broker.TransportConnection)
      [ActiveMQ BrokerService[localhost] Task-2]
      [exec] 14 Dec 2020 15:41:32 | INFO Connector vm://localhost
      stopped (org.apache.activemq.broker.TransportConnector) [ActiveMQ
      ShutdownHook]
      [exec] 14 Dec 2020 15:41:32 |
      INFO PListStore:[/home/martijn/git/ciphermail-core/var/jms-
      data/localhost/tmp_storage]
      stopped (org.apache.activemq.store.kahadb.plist.PListStoreImpl)
      [ActiveMQ ShutdownHook]
      [exec] 14 Dec 2020 15:41:32 | INFO Stopping async queue
      tasks (org.apache.activemq.store.kahadb.KahaDBStore) [ActiveMQ
      ShutdownHook]
      [exec] 14 Dec 2020 15:41:32 | INFO Stopping async topic
      tasks (org.apache.activemq.store.kahadb.KahaDBStore) [ActiveMQ
      ShutdownHook]
      [exec] 14 Dec 2020 15:41:32 | DEBUG Forcing shutdown of
      ExecutorService:
      org.apache.activemq.store.kahadb.KahaDBStore$StoreTaskExecutor@7ae5430d
      [Running, pool size = 0, active threads = 0, queued tasks = 0,
      completed tasks = 0] (org.apache.activemq.util.ThreadPoolUtils)
      [ActiveMQ ShutdownHook]
      [exec] 14 Dec 2020 15:41:32 | DEBUG Shutdown of ExecutorService:
      java.util.concurrent.ThreadPoolExecutor@7cd2745d[Terminated, pool size
      = 0, active threads = 0, queued tasks = 0, completed tasks = 1] is
      shutdown: true and terminated: false took: 0.000
      seconds. (org.apache.activemq.util.ThreadPoolUtils) [ActiveMQ
      Connection Executor: vm://localhost#0]
      [exec] 14 Dec 2020 15:41:32 | DEBUG Forcing shutdown of
      ExecutorService:
      org.apache.activemq.store.kahadb.KahaDBStore$StoreTaskExecutor@30030b95
      [Running, pool size = 0, active threads = 0, queued tasks = 0,
      completed tasks = 0] (org.apache.activemq.util.ThreadPoolUtils)
      [ActiveMQ ShutdownHook]
      [exec] 14 Dec 2020 15:41:32 | INFO Stopped
      KahaDB (org.apache.activemq.store.kahadb.KahaDBStore) [ActiveMQ
      ShutdownHook]
      [exec] 14 Dec 2020 15:41:32 | DEBUG Shutdown of ExecutorService:
      java.util.concurrent.ThreadPoolExecutor@14ef957c[Shutting down, pool
      size = 1, active threads = 1, queued tasks = 1, completed tasks = 0] is
      shutdown: true and terminated: false took: 0.000
      seconds. (org.apache.activemq.util.ThreadPoolUtils) [ActiveMQ
      Connection Executor: vm://localhost#0]
      [exec] 14 Dec 2020 15:41:32 | DEBUG Forcing shutdown of
      ExecutorService:
      java.util.concurrent.ThreadPoolExecutor@7a50bc0d[Running, pool size =
      2, active threads = 0, queued tasks = 0, completed tasks =
      6] (org.apache.activemq.util.ThreadPoolUtils) [ActiveMQ Connection
      Executor: vm://localhost#0]
      [exec] 14 Dec 2020 15:41:32 | DEBUG Checkpoint
      started. (org.apache.activemq.store.kahadb.MessageDatabase)
      [ActiveMQ ShutdownHook]
      [exec] 14 Dec 2020 15:41:32 | DEBUG Checkpoint
      done. (org.apache.activemq.store.kahadb.MessageDatabase) [ActiveMQ
      ShutdownHook]
      [exec] java.lang.Thread.getStackTrace(Thread.java:1559)
      [exec]
      org.apache.activemq.broker.BrokerService.start(BrokerService.java:612)
      [exec]
      org.apache.activemq.transport.vm.VMTransportFactory.doCompositeConnect(
      VMTransportFactory.java:127)
      [exec]
      org.apache.activemq.transport.vm.VMTransportFactory.doConnect(VMTranspo
      rtFactory.java:56)
      [exec]
      org.apache.activemq.transport.TransportFactory.connect(TransportFactory
      .java:65)
      [exec]
      org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQC
      onnectionFactory.java:331)
      [exec]
      org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(
      ActiveMQConnectionFactory.java:346)
      [exec]
      org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(
      ActiveMQConnectionFactory.java:304)
      [exec]
      org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQ
      ConnectionFactory.java:244)
      [exec]
      org.springframework.jms.connection.SingleConnectionFactory.doCreateConn
      ection(SingleConnectionFactory.java:342)
      [exec]
      org.springframework.jms.connection.SingleConnectionFactory.initConnecti
      on(SingleConnectionFactory.java:288)
      [exec]
      org.springframework.jms.connection.SingleConnectionFactory.createConnec
      tion(SingleConnectionFactory.java:225)
      [exec]
      org.springframework.jms.support.JmsAccessor.createConnection(JmsAccesso
      r.java:184)
      [exec]
      org.springframework.jms.listener.AbstractJmsListeningContainer.createSh
      aredConnection(AbstractJmsListeningContainer.java:405)
      [exec]
      org.springframework.jms.listener.AbstractJmsListeningContainer.refreshS
      haredConnection(AbstractJmsListeningContainer.java:390)
      [exec]
      org.springframework.jms.listener.DefaultMessageListenerContainer.refres
      hConnectionUntilSuccessful(DefaultMessageListenerContainer.java:885)
      [exec]
      org.springframework.jms.listener.DefaultMessageListenerContainer.recove
      rAfterListenerSetupFailure(DefaultMessageListenerContainer.java:861)
      [exec]
      org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncM
      essageListenerInvoker.run(DefaultMessageListenerContainer.java:1012)
      [exec] java.lang.Thread.run(Thread.java:748)
      [exec] 14 Dec 2020 15:41:32 | WARN Memory Usage for the Broker
      (1024mb) is more than the maximum available for the JVM: 455 mb -
      resetting to 70% of maximum available: 318
      mb (org.apache.activemq.broker.BrokerService)
      [org.springframework.jms.listener.DefaultMess

        Attachments

          Activity

            People

            • Assignee:
              mattrpav Matt Pavlovich
              Reporter:
              martijn_brinkers Martijn Brinkers
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: