activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Posta <christian.po...@gmail.com>
Subject Re: question about static network connector?
Date Fri, 08 Nov 2013 15:09:42 GMT
Inline...

BTW... i highly recommend you reading through this wiki closely:
http://activemq.apache.org/networks-of-brokers.html

It has answers to some of your questions :)

On Thu, Nov 7, 2013 at 8:29 PM, smith_jor <acceptany@gmail.com> wrote:
> Now, I have a JDBC master/slave cluster: tcp://remote1:61616,
> tcp://remote2:61616, tcp:/remote3:61616
>
> I start a VM , application write message to VM, then VM forward messages to
> this master/slave cluster.
>
> core code is below:
>
>  ActiveMQConnectionFactory factory = new
>
> ActiveMQConnectionFactory("vm:(broker:(network:static:(tcp://remote1:61616,tcp://remote2:61616,tcp://remote3:61616))?persistent=false)");
>
>
>                 Connection connection = factory.createConnection();
>                 Session session = connection.createSession(false,
>                                 Session.AUTO_ACKNOWLEDGE);
>                 connection.start();
>                 Queue queue = session.createQueue("test");
>                 MessageProducer producer = session.createProducer(queue);
>                 // send messages
>                 for (int i = 0; i < 1000000000; i++) {
>                         producer.send(session.createTextMessage(i + " message"));
>                         System.out.println("Sent message " + i);
>                         Thread.sleep(1000);
>                 }
>                 producer.close();
>                 session.close();
>                 connection.close();
>
>
> But , there is a exception like this;
>
> Exception in thread "main" javax.jms.JMSException: Peer (vm://localhost#7)
> disposed.
>         at
> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
>         at
> org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1409)
>         at
> org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1319)
>         at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1798)
>         at
> org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:289)
>         at
> org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:224)
>         at
> org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241)
>         at com.test.EmbeddedProducer.main(EmbeddedProducer.java:25)
> Caused by: org.apache.activemq.transport.TransportDisposedIOException: Peer
> (vm://localhost#7) disposed.
>         at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:89)
>         at
> org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)
>         at
> org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81)
>         at
> org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:86)
>         at
> org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1380)
>         ... 6 more
>
> why throw this exception, is there some thing wrong in code ?
Does this happen right away? Or after some messages get sent? Anything
else in the logs concerning ActiveMQ?

>
> what is difference between
>  ActiveMQConnectionFactory factory = new
>
> ActiveMQConnectionFactory("vm:(broker:(network:static:(tcp://remote1:61616,tcp://remote2:61616,tcp://remote3:61616))?persistent=false)");
>
> and
>
>
>  ActiveMQConnectionFactory factory = new
>
> ActiveMQConnectionFactory("vm:(broker:(network:masterslave:(tcp://remote1:61616,tcp://remote2:61616,tcp://remote3:61616))?persistent=false)");

masterslave: protocol will use the failover() transport under the
covers (with appropriate settings) and reduce warning logs about not
being able to connect to the other brokers...

>
> another question:
>
> if I use network:static(uri1,uri2, ...,uriN)
> should a message forward to all these uris?
>
Well.. it will try to open a network bridge to all of those brokers.
If they're up, then yes, you could potentially have messages forwarded
to all of them. In your case, you mention that you have M/S failover
on JDBC, so the slave brokers are not fully started. The network
bridge won't be able to connect to them because they're not fully up,
so you won't end up with a situation where messages get forwarded to
all of them.

> or forward to only one  url ?
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/question-about-static-network-connector-tp4674057.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



-- 
Christian Posta
http://www.christianposta.com/blog
twitter: @christianposta

Mime
View raw message