[ 
https://issues.apache.org/jira/browse/AMQ-6960?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maor Blumenfeld closed AMQ-6960.
--------------------------------
    Resolution: Workaround

I managed to add the network connectors 
not with the proxy (BrokerViewMBean), but with the broker itself 
(BrokerService). 
This is the code that adds a new network connector (similar to how 
activemq code handles a new network connector):

 

NetworkConnector networkConnector = 
m_broker.addNetworkConnector(friendBrokerUrl); 
        networkConnector.setName(DEFAULT_NETWORK_CONNECTOR_NAME + "_" + 
friendBrokerName + "_" + serviceName.toLowerCase()); 
        networkConnector.setLocalUri(m_broker.getVmConnectorURI()); 
        networkConnector.setBrokerName(m_broker.getBrokerName()); 
        
networkConnector.setDurableDestinations(m_broker.getBroker().getDurableDestinations());
 
        if(m_broker.getDefaultSocketURIString() != null) { 
            
networkConnector.setBrokerURL(m_broker.getDefaultSocketURIString()); 
        } 

        // register network connector MBean 
        m_broker.registerNetworkConnectorMBean(networkConnector); 

        // start network connector 
        networkConnector.start();

> Add method BrokerView.addNetworkConnector(String discoveryAddress, String  
> networkConnectorName)
> ------------------------------------------------------------------------------------------------
>
>                 Key: AMQ-6960
>                 URL: https://issues.apache.org/jira/browse/AMQ-6960
>             Project: ActiveMQ
>          Issue Type: New Feature
>          Components: Broker
>            Reporter: Maor Blumenfeld
>            Priority: Major
>
> After a broker has started, when adding a network connector (broker2),
>  the first one goes OK:
> {{// create network connector over JMX
> ObjectName brokerObjectName = new 
> ObjectName("org.apache.activemq:type=Broker,brokerName=" + broker1Name);
> BrokerViewMBean proxyBroker = (BrokerViewMBean) 
> broker.getManagementContext().newProxyInstance(brokerObjectName, 
> BrokerViewMBean.class, true);
> // let's add the NC String
> networkConnectorName = 
> proxyBroker.addNetworkConnector("static://"+urlBroker2); }}
> Sometime after I try to add another network connector (broker3):
> {{
> brokerObjectName = new 
> ObjectName("org.apache.activemq:type=Broker,brokerName=" + broker1Name);
> proxyBroker = (BrokerViewMBean) 
> broker.getManagementContext().newProxyInstance(brokerObjectName, 
> BrokerViewMBean.class, true);
> // let's add the NC networkConnectorName = 
> proxyBroker.addNetworkConnector("static://"+urlBroker3); }}
> This time it fails with this exception:
> Caused by: javax.management.InstanceAlreadyExistsException: 
> org.apache.activemq:type=Broker,brokerName=ig2-1,connector=networkConnectors,networkConnectorName=NC
>  at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
> This appears to be a consequence of the fact that 
> org.apache.activemq.network.NetworkBridgeConfiguration.name is defaulted to 
> "NC" and there's not a way to set it to another value when calling 
>  org.apache.activemq.broker.jmx.BrokerView.addNetworkConnector(String) nor 
>  to rename it after it's created.
> To solve this problem, please add support for the following method:
>  BrokerView.addNetworkConnector(String discoveryAddress, String 
> networkConnectorName) 
> to allow the network connector name to be specified by the caller. 
> Thanks,
> Maor



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to