3 Replies Latest reply on Dec 22, 2009 9:44 AM by timfox

    Reconnect durable subscribers problem

    fredrikj

      Hi.

      We are trying the following scenario:

       

      • A HornetQ broker running.
      • A producer (P1) running and producing messages
      • A consumer (C1) running

       

      The consumer (C1) is a durable consumer with client id, set on ConnectionFactory, "ABC" and subscriber name set in the 'createDurableSubscriber' method is also "ABC". The consumer is working and all events are piped through.

       

      We now kill the consumer process. The queue is now building up on the broker as expected. The producer P1 is then killed, and we end up with a fixed size queue on the server.

       

      We now try to start a new consumer process (C2) which should consume the lingering queue. We use the same client id and subscriber name, i.e. "ABC".

       

      Our expectancy is that the consumer will connect to the broker and retrieve the remaining queue. However, this fails with the error:

      "Cannot  create a subscriber on the durable subscription since it already has  subscriber"

       

      We can clearly see in HornetQSession that this error is thrown when a consumer is still registered in the broker. Through JMX we can see that the consumer count before starting C2 is still 1. This is assumed to be associated with C1.

       

      So, our question is: how can we get this scenario to work?

       

      Arguably, C2 should overtake C1's consumer connection. If that is not possible, how can we make sure that the registered consumer for C1 is removed from the broker as quickly as possible. It is not acceptable for us to have lingering connections from killed processes that blocks a new durable subscriber for more than a few seconds. In the case of a crash or downtime we must be able to restart the consumers fast or the entire idea of durable consumers is a lost cause.

       

      Cheers