Uploaded image for project: 'ServiceMix'
  1. ServiceMix
  2. SM-1964

JMS Flow only uses one connection even with a PooledConnectionFactory

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.2
    • Fix Version/s: 3.4.0
    • Component/s: servicemix-core
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      The AbstractJMSFlow uses only one connection for routing. It should take advantage of a connection pool if that's the case, but there is a bit of an edge case where this is actually a more severe issue.

      If the flow is defined such that:

      • during the flow messages are produced and send back to a queue and
      • a failover transport is used (which uses a MutexTransport internally) and
      • the broker where we enqueue is slow

      then the producer will wait for the slow broker, but in the meantime will hold the mutex, preventing all the consumers in all the threads to consume which will lead (potentially) to queues filling up on the broker and pretty much everything grinding to a halt.

      Proposed patch to follow shortly.

      1. PooledConnectionFix.patch
        1 kB
        Suresh Avadhanula
      2. sm-1964-2.patch
        1 kB
        Hadrian Zbarcea
      3. smx-1964.patch
        2 kB
        Hadrian Zbarcea

        Activity

        Hide
        hadrian Hadrian Zbarcea added a comment -

        Patch attached, I'll try to put together a unit test as well.

        Show
        hadrian Hadrian Zbarcea added a comment - Patch attached, I'll try to put together a unit test as well.
        Hide
        ccustine Chris Custine added a comment -

        Patch applied, with thanks to Hadrian Zbarcea.

        Show
        ccustine Chris Custine added a comment - Patch applied, with thanks to Hadrian Zbarcea.
        Hide
        hadrian Hadrian Zbarcea added a comment -

        Adding missing check.

        Show
        hadrian Hadrian Zbarcea added a comment - Adding missing check.
        Hide
        hadrian Hadrian Zbarcea added a comment -

        First patch was incomplete, see second one. If the pool only has one connection it's used for the broadcast, so that one should be used.

        Show
        hadrian Hadrian Zbarcea added a comment - First patch was incomplete, see second one. If the pool only has one connection it's used for the broadcast, so that one should be used.
        Hide
        jgoodyear Jamie goodyear added a comment -

        Patch applied, with thanks to Hadrian Zbarcea.

        Sending core/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jms/AbstractJMSFlow.java
        Transmitting file data .
        Committed revision 966303.

        Show
        jgoodyear Jamie goodyear added a comment - Patch applied, with thanks to Hadrian Zbarcea. Sending core/servicemix-core/src/main/java/org/apache/servicemix/jbi/nmr/flow/jms/AbstractJMSFlow.java Transmitting file data . Committed revision 966303.
        Hide
        avadhanula Suresh Avadhanula added a comment -

        Fix bugs in AbstractJMSFlow support for PooledConnection

        Show
        avadhanula Suresh Avadhanula added a comment - Fix bugs in AbstractJMSFlow support for PooledConnection
        Hide
        avadhanula Suresh Avadhanula added a comment -

        The code breaks when using servicemix with pooled connection

        Show
        avadhanula Suresh Avadhanula added a comment - The code breaks when using servicemix with pooled connection
        Hide
        avadhanula Suresh Avadhanula added a comment -

        The patch introduced bugs whereby the connection is closed the first time it is used and henceforth throws the following exception

        javax.jbi.messaging.MessagingException: org.apache.activemq.AlreadyClosedException: this connection
        at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow.doRouting(AbstractJMSFlow.java:504)
        at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow.doSend(AbstractJMSFlow.java:432)
        at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.send(AbstractFlow.java:124)
        at org.apache.servicemix.jbi.nmr.DefaultBroker.sendExchangePacket(DefaultBroker.java:283)
        at org.apache.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java:903)
        at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:405)
        at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImpl.java:441)
        at org.apache.servicemix.components.util.PojoSupport.done(PojoSupport.java:200)
        at com.dorado.servicemix.client.DOSMXClient.onMessageExchange(DOSMXClient.java:288)
        at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:632)
        at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:185)
        at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow.access$401(AbstractJMSFlow.java:64)
        at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow$4.run(AbstractJMSFlow.java:533)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
        at java.lang.Thread.run(Thread.java:595)
        Caused by: org.apache.activemq.AlreadyClosedException: this connection
        at org.apache.activemq.pool.PooledConnection.assertNotClosed(PooledConnection.java:161)
        at org.apache.activemq.pool.PooledConnection.start(PooledConnection.java:77)
        at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow.doRouting(AbstractJMSFlow.java:480)

        I attached the fix in the patch

        Show
        avadhanula Suresh Avadhanula added a comment - The patch introduced bugs whereby the connection is closed the first time it is used and henceforth throws the following exception javax.jbi.messaging.MessagingException: org.apache.activemq.AlreadyClosedException: this connection at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow.doRouting(AbstractJMSFlow.java:504) at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow.doSend(AbstractJMSFlow.java:432) at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.send(AbstractFlow.java:124) at org.apache.servicemix.jbi.nmr.DefaultBroker.sendExchangePacket(DefaultBroker.java:283) at org.apache.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java:903) at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:405) at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImpl.java:441) at org.apache.servicemix.components.util.PojoSupport.done(PojoSupport.java:200) at com.dorado.servicemix.client.DOSMXClient.onMessageExchange(DOSMXClient.java:288) at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:632) at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:185) at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow.access$401(AbstractJMSFlow.java:64) at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow$4.run(AbstractJMSFlow.java:533) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676) at java.lang.Thread.run(Thread.java:595) Caused by: org.apache.activemq.AlreadyClosedException: this connection at org.apache.activemq.pool.PooledConnection.assertNotClosed(PooledConnection.java:161) at org.apache.activemq.pool.PooledConnection.start(PooledConnection.java:77) at org.apache.servicemix.jbi.nmr.flow.jms.AbstractJMSFlow.doRouting(AbstractJMSFlow.java:480) I attached the fix in the patch
        Hide
        jbonofre Jean-Baptiste Onofré added a comment -

        Revision 1071964.

        Show
        jbonofre Jean-Baptiste Onofré added a comment - Revision 1071964.

          People

          • Assignee:
            jbonofre Jean-Baptiste Onofré
            Reporter:
            hadrian Hadrian Zbarcea
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development