[rabbitmq-discuss] ConnectionFactory.newConnection(Address[] addrs) is very slow

Simon MacMullen simon at rabbitmq.com
Thu Apr 25 14:33:01 BST 2013


I note that your connection is stuck in java.net.Socket.connect(). I 
assume that this means there is some local network issue which is 
causing attempts to connect to the stopped node to take a long time to 
time out.

As far as I can see you're using newConnection(Address[]) correctly, but 
you may have a network problem. (a badly implemented firewall maybe?)

Cheers, Simon

On 23/04/13 17:16, hwang wrote:
> Recently I begin to use rabbitMQ, but encounter a strange problem. I use
> the method newConnection(Address[] addrs) of class ConnectionFactory
> when I initial the connection, because the document said that this
> method will pick up one available address automatically. The code looks
> like below in function setup():
>
> |String[] mqAddrArr = new String[] {
>      "node1:5672", "node2:5672"
> };
> connection = connectionFactory.newConnection(mqAddrArr);
> |
>
> In my code, if encounter a ShutdownSignalException, I will catch it and
> re-connect(using the same setup() method).
>
> When I start the application, this newConnection(mqAddrArr) run
> normally. As I run "rabbitmqctl stop" on node1, the program can catch
> the ShutdownSignalException rightly and run setup() to re-connect.
>
> But this time, the newConnection(mqAddrArr) is very slow, maybe about
> 2-3 minutes to re-connect succeed.
>
> I'm wondering if this is the right performance of method
> newConnection(Address[] addrs), or maybe there is some parameter I can
> set to control the re-connect time?
>
> When the newConnection method halt, I get some jstack information in the
> last, maybe helpful.
>
> Thanks.
>
> |"Finalizer" daemon prio=10 tid=0x09f44400 nid=0x3e70 in Object.wait() [0x7c51c000]
>     java.lang.Thread.State: WAITING (on object monitor)
>      at java.lang.Object.wait(Native Method)
>      - waiting on <0xa522f340> (a java.lang.ref.ReferenceQueue$Lock)
>      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:133)
>      - locked <0xa522f340> (a java.lang.ref.ReferenceQueue$Lock)
>      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:149)
>      at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)
>
> "Reference Handler" daemon prio=10 tid=0x09f3f800 nid=0x3e6f in Object.wait() [0x7c56d000]
>     java.lang.Thread.State: WAITING (on object monitor)
>      at java.lang.Object.wait(Native Method)
>      - waiting on <0xa522ef10> (a java.lang.ref.Reference$Lock)
>      at java.lang.Object.wait(Object.java:502)
>      at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
>      - locked <0xa522ef10> (a java.lang.ref.Reference$Lock)
>
> "main" prio=10 tid=0x09e94000 nid=0x3e68 runnable [0xb776a000]
>     java.lang.Thread.State: RUNNABLE
>      at java.net.PlainSocketImpl.socketConnect(Native Method)
>      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
>      - locked <0xa470f390> (a java.net.SocksSocketImpl)
>      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
>      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
>      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
>      at java.net.Socket.connect(Socket.java:546)
>      at com.rabbitmq.client.ConnectionFactory.createFrameHandler(ConnectionFactory.java:445)
>      at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:504)
>      at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:488)
>      at com.wandoujia.storage.rabbitmq.RabbitMQReceiver.setup(RabbitMQReceiver.java:114)
>      at com.wandoujia.storage.rabbitmq.RabbitMQReceiver.reconnect(RabbitMQReceiver.java:105)
>      at com.wandoujia.storage.rabbitmq.RabbitMQReceiver.ack(RabbitMQReceiver.java:141)
>      at com.wandoujia.storage.rabbitmq.testMQReceiver.test(testMQReceiver.java:21)
>      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>      at java.lang.reflect.Method.invoke(Method.java:616)
>      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>      at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
>      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
>      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
>      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)|
>
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>


-- 
Simon MacMullen
RabbitMQ, VMware


More information about the rabbitmq-discuss mailing list