6 Replies Latest reply on Dec 14, 2011 2:38 PM by eparchas

    Question about timeout on blocking send

    karlicontrol

      I'm hoping someone can clarify how to set a timeout on a blocking send -- i.e. if the send has not completed successfully within X time, the send call should throw an exception.

       

      I have poked around the docs and API and found a setting called "setCallTimeout" on the connection factory.  However, when I tested it, it did not seem to exit the call after that timeout.

       

      I see on ClientSession that get/set transaction timeouts are part of the XA interface, making me believe that they would not help me, since I am using regular transacted sessions, not XA.

       

      Any idea how to achieve what I want?  It's all right if occasionally duplicates get through -- I just don't want clients blocked in a send() call for more than a configurable period of time.

       

      Thanks.

      Karl

        • 1. Re: Question about timeout on blocking send
          clebert.suconic

          blocking send will only protect you for network failures. (Say if the server failed, hang during the protocol iterations between your client and server). You shouldn't see any timeout under regular circunstances.

          • 2. Re: Question about timeout on blocking send
            clebert.suconic

            (also, or eventually the server is too busy processing requests.. however HornetQ handles load pretty well... so you really need to pound the server beyond its limits to make this happen)

            • 3. Re: Question about timeout on blocking send
              karlicontrol

              Thanks Clebert.

               

              I actually would want it to time out as a defensive mechanism, similar to an overall call timeout or transaction timeout on a database query, to prevent the system from locking up.  I take it there is no way to it at this time?

               

              Karl

              • 4. Re: Question about timeout on blocking send
                clebert.suconic

                HornetQ is not a database, hence you won't see a scenario like in a database that a TX will be waiting something to release the lock on the server.

                 

                the only scenario a commit will take more than X seconds to happen is if you have resources issues or network issues, on which case you get a timetout.

                 

                 

                I'm a little confused though, if you meant TX timeout for an opened TX. (say you left your TX open for a long time, without a commit)

                • 5. Re: Question about timeout on blocking send
                  leomrlima

                  Hello!

                   

                  For this cases (server failure), what will happen?

                   

                  I had a case of "no space left on device" and my producers where left hanging. I don't know if they hang because of address_full_policy = BLOCK, or because of something else (I have no logs, because, the server had no space left on disk). Also, I'm about to test "sudden shutdowns" (to mimic power failures) and I'll surely have "network failures" as well. Can something be done to set a timeout in these cases? A timeout would be a given time after the QueueClient.send() message was called.

                   

                  The stacktrace of hang:

                  Thread: Receiver-13932 : priority:5, demon:true, threadId:27404, threadState:WAITING

                      - waiting on <0x6cb562a2> (a java.util.concurrent.Semaphore$NonfairSync)
                      sun.misc.Unsafe.park(Native Method)
                      java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
                      java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
                      java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:969)
                      java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1281)
                      java.util.concurrent.Semaphore.acquire(Semaphore.java:441)
                      org.hornetq.core.client.impl.ClientProducerCreditsImpl.acquireCredits(ClientProducerCreditsImpl.java:67)
                      org.hornetq.core.client.impl.ClientProducerImpl.doSend(ClientProducerImpl.java:303)
                      org.hornetq.core.client.impl.ClientProducerImpl.send(ClientProducerImpl.java:139)
                      org.hornetq.jms.client.HornetQMessageProducer.doSend(HornetQMessageProducer.java:451)
                      org.hornetq.jms.client.HornetQMessageProducer.send(HornetQMessageProducer.java:199)

                   

                  Thanks in advance,

                  Leo.

                  • 6. Re: Question about timeout on blocking send
                    eparchas

                    I would also be interested in configuring a send timeout. In my case I have queue configured with fixed size and no paging (BLOCK) and would like the producers to back off when the queue is full (i.e. when they cannot put a message in a queue for a certain timeout). Is there a way to configure such a timeout on the connection factory?