You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by yair <ya...@sundaysky.com> on 2010/01/14 17:02:21 UTC

Visibility timeout feature

hi all
I m currently using amazon's SQS as a queue for jobs running in my systems.
When a "worker" machine takes a job from the queue, it becomes invisible to
other workers. The queue has a configurable timeout, so that if in X seconds
the worker didn't deleted the message completely from the queue, it will
return to the queue.

I m trying to make this work in ActiveMQ instead of SQS. I m using sessions
to commit after receiving messages, so that if a machine will crush (thus
closing the connection) the message will stay in the queue (this works
fine). However, i want it to also use some timeout to return the message to
the queue. Is this possible in ActiveMQ?

thanks
Yair

-- 
View this message in context: http://old.nabble.com/Visibility-timeout-feature-tp27163663p27163663.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Visibility timeout feature

Posted by Rob Davies <ra...@gmail.com>.
Yes - you do need to use a separate Session for each thread in that case

cheers,

Rob
On 17 Jan 2010, at 15:56, yair wrote:

>
> Thanks again.
>
> I have a problem with that:
> I pop a message in one thread, work on it, and after a few seconds I  
> am
> finished with it and then I need to commit (so that the job will be  
> removed
> from the queue). I want to use the commit method of the consumer  
> object.
> While the message in "invisible" (between popping and committing),  
> another
> thread tries to do the same. This is problematic because this  
> consumer is in
> the middle of a transaction with the first thread. So I am creating a
> consumer for each thread.
> The problem is that committing on the consumer object doesn't seems to
> delete the messages from the queue.
>
> Does this means I need to create a session for each thread and  
> commit using
> the session object?
>
> Thanks
> Yair
>
> -- 
> View this message in context: http://old.nabble.com/Visibility-timeout-feature-tp27163663p27200125.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Rob Davies
http://twitter.com/rajdavies
I work here: http://fusesource.com
My Blog: http://rajdavies.blogspot.com/
I'm writing this: http://www.manning.com/snyder/






Re: Visibility timeout feature

Posted by yair <ya...@sundaysky.com>.
Thanks again.

I have a problem with that:
I pop a message in one thread, work on it, and after a few seconds I am
finished with it and then I need to commit (so that the job will be removed
from the queue). I want to use the commit method of the consumer object.
While the message in "invisible" (between popping and committing), another
thread tries to do the same. This is problematic because this consumer is in
the middle of a transaction with the first thread. So I am creating a
consumer for each thread.
The problem is that committing on the consumer object doesn't seems to
delete the messages from the queue.

Does this means I need to create a session for each thread and commit using
the session object?

Thanks
Yair

-- 
View this message in context: http://old.nabble.com/Visibility-timeout-feature-tp27163663p27200125.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Visibility timeout feature

Posted by Rob Davies <ra...@gmail.com>.
Hi Yair,

yes - only create consumer and session once and  reuse them - see this  
for more details: http://activemq.apache.org/how-do-i-use-jms-efficiently.html

cheers,

Rob
On 17 Jan 2010, at 11:56, yair wrote:

>
> Thanks for your answer, Rob.
>
> I want to make sure what I do is correct:
> I create a connection factory, and create a connection from it.
> Then each time i want to pop a message, I create a  
> session(transacted=true),
> create a consumer, receive, and commit or rollback. For each message  
> popped,
> I am creating a session and consumer again.
>
> Is that ok? can I create a session only once? and a consumer?
>
> thanks
> Yair
>
> -- 
> View this message in context: http://old.nabble.com/Visibility-timeout-feature-tp27163663p27198059.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Rob Davies
http://twitter.com/rajdavies
I work here: http://fusesource.com
My Blog: http://rajdavies.blogspot.com/
I'm writing this: http://www.manning.com/snyder/






Re: Visibility timeout feature

Posted by yair <ya...@sundaysky.com>.
Thanks for your answer, Rob.

I want to make sure what I do is correct:
I create a connection factory, and create a connection from it.
Then each time i want to pop a message, I create a session(transacted=true),
create a consumer, receive, and commit or rollback. For each message popped,
I am creating a session and consumer again.

Is that ok? can I create a session only once? and a consumer?

thanks
Yair

-- 
View this message in context: http://old.nabble.com/Visibility-timeout-feature-tp27163663p27198059.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Visibility timeout feature

Posted by Rob Davies <ra...@gmail.com>.
Hi Yair,

We don't currently support the timeout feature - but if you could add  
an enhancement request - we'll try fit in 5.4

thanks,

Rob
On 14 Jan 2010, at 16:02, yair wrote:

>
> hi all
> I m currently using amazon's SQS as a queue for jobs running in my  
> systems.
> When a "worker" machine takes a job from the queue, it becomes  
> invisible to
> other workers. The queue has a configurable timeout, so that if in X  
> seconds
> the worker didn't deleted the message completely from the queue, it  
> will
> return to the queue.
>
> I m trying to make this work in ActiveMQ instead of SQS. I m using  
> sessions
> to commit after receiving messages, so that if a machine will crush  
> (thus
> closing the connection) the message will stay in the queue (this works
> fine). However, i want it to also use some timeout to return the  
> message to
> the queue. Is this possible in ActiveMQ?
>
> thanks
> Yair
>
> -- 
> View this message in context: http://old.nabble.com/Visibility-timeout-feature-tp27163663p27163663.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>