Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 44746 invoked from network); 6 Dec 2007 20:21:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Dec 2007 20:21:37 -0000 Received: (qmail 44355 invoked by uid 500); 6 Dec 2007 20:21:25 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 44325 invoked by uid 500); 6 Dec 2007 20:21:24 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 44316 invoked by uid 99); 6 Dec 2007 20:21:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2007 12:21:24 -0800 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2007 20:21:24 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1J0NDT-0004X4-Kt for users@activemq.apache.org; Thu, 06 Dec 2007 12:21:03 -0800 Message-ID: <14200217.post@talk.nabble.com> Date: Thu, 6 Dec 2007 12:21:03 -0800 (PST) From: Jason Rosenberg To: users@activemq.apache.org Subject: Test-case for problem with connections not refreshing when pooled with failover In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: jrosenberg@shopzilla.com References: <13292887.post@talk.nabble.com> <47189CDC.9050702@tid.es> <13293655.post@talk.nabble.com> <13293740.post@talk.nabble.com> <4718ABD1.3030702@tid.es> <13294714.post@talk.nabble.com> <13958172.post@talk.nabble.com> <13969349.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org James, I've created a test-case here, which demonstrates clearly the main problem, with connections created with a pooledConnection don't recover quickly, when a broker becomes available, when the failover transport is used, with a maxReconnectAttempts setting. Attached is a source tar file, which you can extract and build, with maven. It should build a web-app war file, which you can drop into tomcat (or probably any j2ee container). I have been using java 1.6 and maven 2.0.7, although I don't know that those should be required. The web-app implements a simple web-service (implemented with CXF)..... It exposes three methods: /pingTcp /pingFailover /pintFailoverWithMaxAttempts Which use respectively, these 3 broker uri's, respectively: tcp://localhost:61616 failover:(tcp://localhost:61616,tcp://localhost:61626)?initialReconnectDelay=20&maxReconnectDelay=500&randomize=false failover:(tcp://localhost:61616,tcp://localhost:61626)?initialReconnectDelay=20&maxReconnectDelay=500&randomize=false&maxReconnectAttempts=2 All the ping method does is create a connection (without actually trying to do anything with it). Assuming you have the web-app deployed in tomcat, running on port 8080, you'd hit the different methods as such: http://localhost:8080/failover-test-web-1.0/FailoverTest/pingTcp http://localhost:8080/failover-test-web-1.0/FailoverTest/pingFailover http://localhost:8080/failover-test-web-1.0/FailoverTest/pingFailoverWithMaxAttempts The connections are created using the activeMQ PooledConnectionFactory class (see the spring template failover-test-ws.xml in the test-case source code). I originally was seeing the problem with the Jencks connection pooling, but it appears to happen also using the activeMQ connection pooling too.... To reproduce the problem, do the following: 1. start with both activemq and tomcat down. 2. start tomcat with the webapp. 3. hit pingFailoverWithMaxAttempts link. it will return a connection error response. 4. Bring up the broker on localhost:61616 5. hit pingFailoverWithMaxAttempts link again, several times. it will continue returning the failed connection link. 6. Wait 3 minutes 7. hit pingFailoverWithMaxAttempts link again. it will finally return successfully, with a good connection So, it takes 3 minutes for it to recognize a recovered broker. Next, repeat the above, this time using the pingTcp link each time. Notice that it recovers immediately. Also, when using the pingFailover method, it generally recovers immediately, but has the downside that it hangs the response until the broker is available (thus the desirability of the maxReconnectAttempts option). There has been suggestion in the forums to use a TransportListener, but it's not obvious to me how one would do this, in a use-case similar to this example, which uses a PooledConnectionFactory, etc. (ideas would be welcome there).... Thanks for any help, Jason http://www.nabble.com/file/p14200217/failover_test_ws.source.tar failover_test_ws.source.tar James.Strachan wrote: > > On 27/11/2007, Jason Rosenberg wrote: >> James, >> >> In this case, I am creating a connection for the purspose of sending a >> message (so not a message listener). I am using the Spring JmsOperations >> template, and just injecting the connectionFactory property for the >> jmsOperations object on initialization. >> >> The connectionFactory is org.jencks.amqpool.PooledConnectionFactory. I >> presume it's up to the factory code to properly dispose of the failed >> connection's resources. I also had the same result configuring it with >> the >> ActiveMQ factory, org.apache.activemq.pool.PooledConnectionFactory. >> >> In each case the pooled connection factories in turn use a >> 'connectionFactory' object of >> org.apache.activemq.ActiveMQConnectionFactory.... >> >> What I've noticed is that this configuration works fine, if I use a >> simple >> TcpTransport. That is, if the connection fails, the connection factory >> seems to dispose of the resources and create a fresh one for the next >> attempt, and so it recovers quickly when the broker recovers. >> >> Somehow, the FailoverTransport must fail in a different way, since the >> connection factory doesn't detect that it needs to remove it and create a >> new object on the next request. >> >> Finally, I've also seen that the FailoverTransport, if configured without >> maxReconnectAttempts, doesn't shutdown cleanly, if there's no broker >> present. It hangs, or throws an exception. I provide the >> destroy-method="stop" on the pooled connection factory object. >> >> Thanks for any help, > > Do you have a test case that demonstrates your issue? > > -- > James > ------- > http://macstrac.blogspot.com/ > > Open Source Integration > http://open.iona.com > > -- View this message in context: http://www.nabble.com/Timeout-and-Failover-on-a-queue-tf4652630s2354.html#a14200217 Sent from the ActiveMQ - User mailing list archive at Nabble.com.