You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Mark Wuwer <m....@googlemail.com> on 2010/11/23 00:10:15 UTC

Re: ActiveMQ and addConnector, addNetworkConnector

 Hi,
I found this posting when searching for issues with adding of multiple
NetworkConnectors.

The problem I have is that when I add the second connector I get the
following exception:
java.io.IOException: Network Connector could not be registered in JMX:
org.apache.activemq:BrokerName=localhost,Type=NetworkConnector,NetworkConnectorName=localhost
    at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
    at
org.apache.activemq.broker.BrokerService.registerNetworkConnectorMBean(BrokerService.java:1699)

This can be reproduced with ActiveMQ 5.4.1 and the following test method
(can be added to e.g. org.apache.activemq.broker.BrokerServiceTest):

    public void testAddRemoveTwoNetworkConnectorsWithJMX() throws
Exception {
        BrokerService service = new BrokerService();
        service.setPersistent(false);
        service.setUseJmx(true);       
       
        NetworkConnector connector1 =
service.addNetworkConnector("static://(tcp://frontend1:61616)"); 
        NetworkConnector connector2 =
service.addNetworkConnector("static://(tcp://frontend2:61616)"); 
        service.start();

        service.removeNetworkConnector(connector1);
        connector1.stop();
        service.removeNetworkConnector(connector2);
        connector2.stop();
        service.stop();
    }

Looking at ActiveMQ code I think I found a  workaround.
When the name of the connector is set before adding it to broker it
works, e.g. like this:

        NetworkConnector connector1 = new DiscoveryNetworkConnector(new
URI("static://(tcp://frontend1:61616)"));
        connector1.setName("frontend1");
        service.addNetworkConnector(connector1); 
        NetworkConnector connector2 = new DiscoveryNetworkConnector(new
URI("static://(tcp://frontend2:61616)"));
        connector2.setName("frontend2");
        service.addNetworkConnector(connector2); 

Anyway, in my opinion it is still an issue, because as far as it is
possible to add a NetworkConnector without setting
a name, the implementation should cope with name == null and e.g.
generate a unique name.

I could not find any related issue, so I guess Ryan did not wrote it as
suggested.

Best regards,
Mark

On 03/18/2010 03:21 PM, Gary Tully wrote:
>
> can you raise an issue for this, with the url you pass to
> addNetworkConnector. I see some of the networkConnectors override the
> getName method to make it unique but not all do.
>
> On 16 March 2010 15:41, Ryan Moquin <fr...@gmail.com> wrote:
>
> > I was experimenting with adding network connectors to ActiveMQ
> through JMX.
> > There is either a problem with the addConnector and addNetworkConnector
> > methods or there is something I'm missing.  If you connect via JMX to
> > ActiveMQ and call the addNetworkConnector JMX method, it works, the
> first
> > time.  The return value from the method is "localhost".  The problem is
> > that
> > when you try to add a second one, the names conflict because that one is
> > also called "localhost" and an exception is thrown.  It doesn't
> appear that
> > there is any addNetworkConnector or addConnector methods that also
> take a
> > name for the connector, are there?  Is there any other way to do this?
> >
> > I'm using Fuse ESB 4.2 and can no longer access the broker directly
> like I
> > could in Fuse ESB 3.x.
> >
> > Ryan
> >
>
>
>
> --
> http://blog.garytully.com
>
> Open Source Integration
> http://fusesource.com
>