You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Daniele Dellafiore <il...@gmail.com> on 2010/06/30 14:24:52 UTC

Reconnect a closed durable subscriber

Hi everyone. I just started using ActiveMQ and this is my first
message to the list.
I have searched for answer for my question on the archive without success.

Quick version: I simply can't find a way to reconnect a durable
subscriber after calling MessageConsumer.close() method to disconnect.

Long version:

I am trying to make a durable subscriber work like in this example:
http://activemq.apache.org/how-do-durable-queues-and-topics-work.html

that is: a disconnected durable subscriber receive all messages
dispatched when he was offline at the moment he reconnects.

So I create a producer and a durable subscriber
I send message M1 and is received. Then I call

consumer.close()

and send M2 which is not received, correctly.
Then I want to reconnect consumer, send M3 and see that consumer
receives M2 and M3.

But I can't find a method or a way to reconnect the subscriber.
What is the right way?

Thanks for any help.

--
Daniele Dellafiore
http://danieledellafiore.net

Re: Reconnect a closed durable subscriber

Posted by Daniele Dellafiore <il...@gmail.com>.
ok, I got it.
The producer must be set in PERSISTENT delivery mode to make this happen.

Thanks for help.

On Thu, Jul 1, 2010 at 11:38 AM, Daniele Dellafiore <il...@gmail.com> wrote:
> I tried this way with no success.
> I create a new subscriber s2b after having called s2a.close(), while
> s1 is always active.
>
> s2b = session.createDurableSubscriber(topic, consumerName);
>
> where session is the same instance I used the first time, so is topic
> and consumerName
>
> after this line, i push new messages on the queue with, from the same producer.
> Now, both s1 and s2b receives this new set of messages, and it is ok.
> What is not right is that I expect that when I reconnect s2b, it
> receives also the messages delivered while he was offline. This last
> thing does not happen.
>
> On Wed, Jun 30, 2010 at 2:33 PM, Stan Lewis <st...@progress.com> wrote:
>> You have to connect to the broker using the same client ID and then
>> create a subscription using the same name as you used previously, that
>> will get you connected to the existing subscription.
>>
>> On Wed, Jun 30, 2010 at 8:24 AM, Daniele Dellafiore <il...@gmail.com> wrote:
>>> Hi everyone. I just started using ActiveMQ and this is my first
>>> message to the list.
>>> I have searched for answer for my question on the archive without success.
>>>
>>> Quick version: I simply can't find a way to reconnect a durable
>>> subscriber after calling MessageConsumer.close() method to disconnect.
>>>
>>> Long version:
>>>
>>> I am trying to make a durable subscriber work like in this example:
>>> http://activemq.apache.org/how-do-durable-queues-and-topics-work.html
>>>
>>> that is: a disconnected durable subscriber receive all messages
>>> dispatched when he was offline at the moment he reconnects.
>>>
>>> So I create a producer and a durable subscriber
>>> I send message M1 and is received. Then I call
>>>
>>> consumer.close()
>>>
>>> and send M2 which is not received, correctly.
>>> Then I want to reconnect consumer, send M3 and see that consumer
>>> receives M2 and M3.
>>>
>>> But I can't find a method or a way to reconnect the subscriber.
>>> What is the right way?
>>>
>>> Thanks for any help.
>>>
>>> --
>>> Daniele Dellafiore
>>> http://danieledellafiore.net
>>>
>>
>
>
>
> --
> Daniele Dellafiore
> http://danieledellafiore.net
>



-- 
Daniele Dellafiore
http://danieledellafiore.net

Re: Reconnect a closed durable subscriber

Posted by Daniele Dellafiore <il...@gmail.com>.
I tried this way with no success.
I create a new subscriber s2b after having called s2a.close(), while
s1 is always active.

s2b = session.createDurableSubscriber(topic, consumerName);

where session is the same instance I used the first time, so is topic
and consumerName

after this line, i push new messages on the queue with, from the same producer.
Now, both s1 and s2b receives this new set of messages, and it is ok.
What is not right is that I expect that when I reconnect s2b, it
receives also the messages delivered while he was offline. This last
thing does not happen.

On Wed, Jun 30, 2010 at 2:33 PM, Stan Lewis <st...@progress.com> wrote:
> You have to connect to the broker using the same client ID and then
> create a subscription using the same name as you used previously, that
> will get you connected to the existing subscription.
>
> On Wed, Jun 30, 2010 at 8:24 AM, Daniele Dellafiore <il...@gmail.com> wrote:
>> Hi everyone. I just started using ActiveMQ and this is my first
>> message to the list.
>> I have searched for answer for my question on the archive without success.
>>
>> Quick version: I simply can't find a way to reconnect a durable
>> subscriber after calling MessageConsumer.close() method to disconnect.
>>
>> Long version:
>>
>> I am trying to make a durable subscriber work like in this example:
>> http://activemq.apache.org/how-do-durable-queues-and-topics-work.html
>>
>> that is: a disconnected durable subscriber receive all messages
>> dispatched when he was offline at the moment he reconnects.
>>
>> So I create a producer and a durable subscriber
>> I send message M1 and is received. Then I call
>>
>> consumer.close()
>>
>> and send M2 which is not received, correctly.
>> Then I want to reconnect consumer, send M3 and see that consumer
>> receives M2 and M3.
>>
>> But I can't find a method or a way to reconnect the subscriber.
>> What is the right way?
>>
>> Thanks for any help.
>>
>> --
>> Daniele Dellafiore
>> http://danieledellafiore.net
>>
>



-- 
Daniele Dellafiore
http://danieledellafiore.net

Re: Reconnect a closed durable subscriber

Posted by Stan Lewis <st...@progress.com>.
You have to connect to the broker using the same client ID and then
create a subscription using the same name as you used previously, that
will get you connected to the existing subscription.

On Wed, Jun 30, 2010 at 8:24 AM, Daniele Dellafiore <il...@gmail.com> wrote:
> Hi everyone. I just started using ActiveMQ and this is my first
> message to the list.
> I have searched for answer for my question on the archive without success.
>
> Quick version: I simply can't find a way to reconnect a durable
> subscriber after calling MessageConsumer.close() method to disconnect.
>
> Long version:
>
> I am trying to make a durable subscriber work like in this example:
> http://activemq.apache.org/how-do-durable-queues-and-topics-work.html
>
> that is: a disconnected durable subscriber receive all messages
> dispatched when he was offline at the moment he reconnects.
>
> So I create a producer and a durable subscriber
> I send message M1 and is received. Then I call
>
> consumer.close()
>
> and send M2 which is not received, correctly.
> Then I want to reconnect consumer, send M3 and see that consumer
> receives M2 and M3.
>
> But I can't find a method or a way to reconnect the subscriber.
> What is the right way?
>
> Thanks for any help.
>
> --
> Daniele Dellafiore
> http://danieledellafiore.net
>