ActiveMQ
  1. ActiveMQ
  2. AMQ-2027

setUseJmx(false) ignored when creating embedded broker.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Not a Problem
    • Affects Version/s: 5.2.0
    • Fix Version/s: 5.2.0
    • Component/s: Broker
    • Labels:
      None
    • Environment:

      Running inside Netbeans environment on a dual-core laptop:
      Product Version: NetBeans IDE 6.1 (Build 200805300101)
      Java: 1.6.0_10; Java HotSpot(TM) Client VM 11.0-b15
      System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)

      Description

      When creating an embedded broker, the BrokerService setUseJmx(false) method appears to be ignored.

      I was using the URI configuration technique, but even explicit setup calls seem to fail.

      Here's an example setup:

      _broker = new BrokerService();
      _broker.setBrokerName("testjms");
      _broker.setPersistent(false);
      _broker.setUseJmx(false);
      _broker.addConnector("tcp://localhost:61616");
      _broker.start();

      When I run the application I get the following messages (note the failure to start the JMX connector at the end):

      09-Dec-2008 16:29:42 org.apache.activemq.broker.BrokerService start
      INFO: Using Persistence Adapter: AMQPersistenceAdapter(activemq-data\aftestjms)
      09-Dec-2008 16:29:42 org.apache.activemq.store.amq.AMQPersistenceAdapter start
      INFO: AMQStore starting using directory: activemq-data\aftestjms
      09-Dec-2008 16:29:42 org.apache.activemq.kaha.impl.KahaStore initialize
      INFO: Kaha Store using data directory activemq-data\aftestjms\kr-store\state
      09-Dec-2008 16:29:42 org.apache.activemq.store.amq.AMQPersistenceAdapter start
      INFO: Active data files: []
      09-Dec-2008 16:29:42 org.apache.activemq.store.amq.AMQPersistenceAdapter start
      WARNING: The ReferenceStore is not valid - recovering ...
      09-Dec-2008 16:29:42 org.apache.activemq.kaha.impl.KahaStore delete
      INFO: Kaha Store successfully deleted data directory activemq-data\aftestjms\kr-store\data
      09-Dec-2008 16:29:42 org.apache.activemq.store.amq.AMQPersistenceAdapter recover
      INFO: Journal Recovery Started from: DataManager:(data-)
      09-Dec-2008 16:29:42 org.apache.activemq.store.amq.AMQPersistenceAdapter recover
      INFO: Recovered 0 operations from redo log in 0.0 seconds.
      09-Dec-2008 16:29:42 org.apache.activemq.store.amq.AMQPersistenceAdapter start
      INFO: Finished recovering the ReferenceStore
      09-Dec-2008 16:29:42 org.apache.activemq.broker.BrokerService getBroker
      INFO: ActiveMQ null JMS Message Broker (aftestjms) is starting
      09-Dec-2008 16:29:42 org.apache.activemq.broker.BrokerService getBroker
      INFO: For help or more information please see: http://activemq.apache.org/
      09-Dec-2008 16:29:42 org.apache.activemq.kaha.impl.KahaStore initialize
      INFO: Kaha Store using data directory activemq-data\aftestjms\kr-store\data
      09-Dec-2008 16:29:42 org.apache.activemq.broker.BrokerService start
      INFO: ActiveMQ JMS Message Broker (aftestjms, ID:LT-BAS-EN-05004-1199-1228840182685-0:0) started
      09-Dec-2008 16:29:42 org.apache.activemq.broker.TransportConnector start
      INFO: Connector vm://aftestjms Started
      Waiting for messages...
      09-Dec-2008 16:29:45 org.apache.activemq.broker.jmx.ManagementContext$1 run
      WARNING: Failed to start jmx connector: Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
      java.net.ConnectException: Connection refused: connect]

      I will attach a sample java souce file.

        Activity

        Hide
        Tim Harris added a comment -

        This wasn't a bug, just a misunderstanding and then some class renaming problems by the bug reporter (me). It is a little odd that in order to not use JMX you have to setUseJms(false) and getManagementContext().setCreateConnector(false) on the broker.
        Apologies,
        Tim

        Show
        Tim Harris added a comment - This wasn't a bug, just a misunderstanding and then some class renaming problems by the bug reporter (me). It is a little odd that in order to not use JMX you have to setUseJms(false) and getManagementContext().setCreateConnector(false) on the broker. Apologies, Tim
        Hide
        Tim Harris added a comment -

        Hi Dejan and Gary,

        My apologies, it appears that I am a muppet.

        _broker.getManagementContext().setCreateConnector(false);

        Works a treat.

        Note the main() in the example code creates a Main class not a useJmsBug class, doh.

        I'll close the issue.

        Show
        Tim Harris added a comment - Hi Dejan and Gary, My apologies, it appears that I am a muppet. _broker.getManagementContext().setCreateConnector(false); Works a treat. Note the main() in the example code creates a Main class not a useJmsBug class, doh. I'll close the issue.
        Hide
        Dejan Bosanac added a comment -

        I just tried your code and everything works fine ... I get all lines until "Waiting for messages..."

        It seems to me that you have something else in your code that tries to use JMX API and fails because it is not started. Maybe a web console?

        Show
        Dejan Bosanac added a comment - I just tried your code and everything works fine ... I get all lines until "Waiting for messages..." It seems to me that you have something else in your code that tries to use JMX API and fails because it is not started. Maybe a web console?
        Hide
        Tim Harris added a comment -

        Yep, I tried that to no effect before submitting the bug, but I will give it another go just in case I was being a muppet.

        Show
        Tim Harris added a comment - Yep, I tried that to no effect before submitting the bug, but I will give it another go just in case I was being a muppet.
        Hide
        Gary Tully added a comment -

        try:

        _broker.getManagementContext().setCreateConnector(false);

        the reference to an MBean server (createCoonnector) and the registration of MBeans (useJMX) with a Server are different at the moment.
        I guess it would make sense if createConnector was conditional on useJMX, not sure why it is not at the moment.

        Show
        Gary Tully added a comment - try: _broker.getManagementContext().setCreateConnector( false ); the reference to an MBean server (createCoonnector) and the registration of MBeans (useJMX) with a Server are different at the moment. I guess it would make sense if createConnector was conditional on useJMX, not sure why it is not at the moment.
        Hide
        Tim Harris added a comment -

        Implementation of a message consumer which also contains an embedded broker. (apologies for the class name)
        Demos the bug.

        Show
        Tim Harris added a comment - Implementation of a message consumer which also contains an embedded broker. (apologies for the class name) Demos the bug.

          People

          • Assignee:
            Unassigned
            Reporter:
            Tim Harris
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development