You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by rmaher <rm...@google.com> on 2006/04/14 07:26:10 UTC

Embedded Networked Brokers

The following code worked with AMQ4 M4

BrokerService brokerService = new BrokerService();
...
String connectors =static://(tcp://127.0.0.1:61616,tcp://127.0.0.1:61626);
brokerService.addNetworkConnector(networkConnector);

but after upgarding to AMQ4 RC2 message fowarding between the two broker no
longer works and I am getting the excpetion below. Any ideas on how to get
this to work?

TIA,

Richard


2006-04-13 22:14:55,655 ERROR [Thread-3]
org.apache.activemq.network.DemandForwardingBridge.error - Failed to start
network bridge: java.net.SocketException: Socket closed
java.net.SocketException: Socket closed
	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
	at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
	at
org.apache.activemq.transport.tcp.TcpBufferedOutputStream.flush(TcpBufferedOutputStream.java:108)
	at java.io.DataOutputStream.flush(DataOutputStream.java:106)
	at
org.apache.activemq.transport.tcp.TcpTransport.oneway(TcpTransport.java:121)
	at
org.apache.activemq.transport.InactivityMonitor.oneway(InactivityMonitor.java:141)
	at
org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.java:86)
	at
org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:77)
	at
org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:44)
	at
org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:55)
	at
org.apache.activemq.network.DemandForwardingBridgeSupport.startRemoteBridge(DemandForwardingBridgeSupport.java:200)
	at
org.apache.activemq.network.DemandForwardingBridgeSupport$4.run(DemandForwardingBridgeSupport.java:163)

--
View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3912634
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Embedded Networked Brokers

Posted by Rob Davies <ra...@gmail.com>.
Richard,

before RC2 the failover tag was automatically injected for networks -  
but IIRC that was changed to be consistent with the way URIs work for  
other connectors and protocols.
For your network URI could you try:

static:failover:(tcp://127.0.0.1:61616,tcp://127.0.0.1:61626)

cheers,

Rob


On 15 Apr 2006, at 02:41, Richard Maher wrote:

>
> I did post the code in a previous message. Here it is again:
>
>     public EmbeddedBroker(List<String> transportConnectors, String
> networkConnector) throws Exception {
>         brokerService.setPersistent(false);
>         brokerService.setUseJmx(false);
>
> brokerService.setTransportConnectorURIs(transportConnectors.toArray 
> (new
> String[0]));
>         if (networkConnector != null)
>             brokerService.addNetworkConnector(networkConnector);
>     }
>
> where transportConnectors is a list of URIs such as "vm://localhost",
> "tcp://localhost:61616", etc...
> and  networkConnector is
> "static://(tcp://127.0.0.1:61616,tcp://127.0.0.1:61626)".
>
> Ther problem I am having is with this URI construct
> "static://(tcp://127.0.0.1:61616,tcp://127.0.0.1:61626)". It use  
> work in M4
> but stopped working in RC2.
>
> Richard
> --
> View this message in context: http://www.nabble.com/Embedded- 
> Networked-Brokers-t1448274.html#a3925718
> Sent from the ActiveMQ - User forum at Nabble.com.
>


Re: Embedded Networked Brokers

Posted by Richard Maher <rm...@google.com>.
I did post the code in a previous message. Here it is again:

    public EmbeddedBroker(List<String> transportConnectors, String
networkConnector) throws Exception {
        brokerService.setPersistent(false);
        brokerService.setUseJmx(false);
       
brokerService.setTransportConnectorURIs(transportConnectors.toArray(new
String[0]));
        if (networkConnector != null)
            brokerService.addNetworkConnector(networkConnector);
    }

where transportConnectors is a list of URIs such as "vm://localhost",
"tcp://localhost:61616", etc...
and  networkConnector is
"static://(tcp://127.0.0.1:61616,tcp://127.0.0.1:61626)". 

Ther problem I am having is with this URI construct
"static://(tcp://127.0.0.1:61616,tcp://127.0.0.1:61626)". It use work in M4
but stopped working in RC2.

Richard
--
View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3925718
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Embedded Networked Brokers

Posted by Adrian Co <ac...@exist.com>.
Could you post your jave code that configures the broker?

Regards,
Adrian Co
--
View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3924932
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Embedded Networked Brokers

Posted by Richard Maher <rm...@google.com>.
I am not using a broker config.xml. The configuration comes from somewhere
else and is injected using Spring. I then have Spring call start for me. My
setup works with M4. It broke after upgrading to RC2.
--
View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3923939
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Embedded Networked Brokers

Posted by Hiram Chirino <hi...@hiramchirino.com>.
If a new connector / transport is added after a broker has been
started, then you need to call .start() on those objects to get them
going.  Otherwise they will not be running.  A subsequent
broker.stop() will stop them.

On 4/15/06, rmoore <ro...@openlogic.com> wrote:
>
> what if the broker is already configured and running and i just want to add a
> new network connector programmatically/dynamically?
>
> thanks.
>
> robert.
>
> --
> View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3935704
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


--
Regards,
Hiram

Re: Embedded Networked Brokers

Posted by rmoore <ro...@openlogic.com>.
what if the broker is already configured and running and i just want to add a
new network connector programmatically/dynamically?

thanks.

robert.

--
View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3935704
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Embedded Networked Brokers

Posted by Adrian Co <ac...@exist.com>.
If you want to configure a broker using spring and pojos, one way is to use
this:

BrokerService brokerService = (new XBeanBrokerFactory()).createBroker(new
URI("xbean:activemq.xml"));
brokerService.addNetworkConnector(...);
brokerService.start();

where activemq.xml is in the classpath. To specify an absolute file path
use: xbean:file:c:/activemq.xml

Regards,
Adrian Co


--
View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3924923
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Embedded Networked Brokers

Posted by rmoore <ro...@openlogic.com>.
thanks for the reply.

how are you using the brokerServer? are you calling start? are you starting
your AMQ brokers via the command line? do you have transport connectors
conigured in your config xml?

i got my replication to work if i do the following:
1. take all of my connector information (transport and connector) out of my
config xml files (one for each broker)
2 . start up two brokers from the command line (using the config xml)
3. start up my consumer class that creates a BrokerService, sets the
transport connector (61617) and the network connector (61616) and calls
broker.start();, then i create a connection using ActiveMQConnectionFactory
connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61617");
and wait for messages.
4. startup my producer the same way as the cosumer and send a message to
61616 (my consumer has a network connector uri for 61616). the replication
across brokers delivers the message to my consumer.

how would i setup just the network connector piece programmatically if i
have the transport connector info set via an xml file? i tried commenting
out broker.setTransportConnectorURIs(transportConnectors);  in both my
producer and consumer and still calling broker.start() and the replication
did not work. is there a way to get a Broker or BrokerService and have it
configured with the info setup in the config.xml used to start activemq?

thanks.

robert.


--
View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3922165
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Embedded Networked Brokers

Posted by Richard Maher <rm...@google.com>.
Not yet. The code is very simple. It looks like this:

    public EmbeddedBroker(List<String> transportConnectors, String
networkConnector) throws Exception {
        brokerService.setPersistent(false);
        brokerService.setUseJmx(false);
       
brokerService.setTransportConnectorURIs(transportConnectors.toArray(new
String[0]));
        if (networkConnector != null)
            brokerService.addNetworkConnector(networkConnector);
    }

where transportConnectors is a list of URIs such as vm://localhost,
tcp://localhost:61616, etc...
and  networkConnector is
static://(tcp://127.0.0.1:61616,tcp://127.0.0.1:61626).

Richard


--
View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3921495
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Embedded Networked Brokers

Posted by rmoore <ro...@openlogic.com>.
have you gotten a reply about your problem?

i too am trying to programmatically add NetworkConnectors so that i can get
broker-to-broker replication. can you post the code you are using to create
new NetworkConnectors? i am trying to use the failover options
(FailoverTransport).

i am having issues in my test code adding NetworkConnectors pointing to the
opposite brokers. 

thanks.

robert.


--
View this message in context: http://www.nabble.com/Embedded-Networked-Brokers-t1448274.html#a3920855
Sent from the ActiveMQ - User forum at Nabble.com.