You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by rbolen <ri...@gxs.com> on 2011/05/05 21:59:51 UTC

Message Groups and long running transactions

We are looking at using message groups (activeMQ V5.5.0).  We are using an
external broker also.  We have a use case where a consumer could be
processing a long running transaction (multiple hours).  

My understanding of message groups is that a group is initially assigned to
a specific consumer and then stays on that consumer until a message comes
through with a -1 group sequence.  But in the case where a consumer is
processing a long transaction for group A and the consumer also has group B
assigned, messages for group B will have to wait for the long running group
A message to complete.  We'd like to avoid this. 

Is it true that even if we send a group B message with sequence -1, it would
only be processed after the long running transaction is complete anyway,
thus defeating the purpose of the -1 sequence?  Or does the broker process
it while the work on the client is being done thus freeing Group B to run on
another consumer.  (We're using prefetch of 1 but we could set it to 0 if it
would help.)

Is there a recommended way to avoid this situation?  Detect the large
payload and pre-emptively send -1 messages?  Create a new consumer
dynamically for large loads?

Thanks,
Rich

--
View this message in context: http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p3499325.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Message Groups and long running transactions

Posted by artnaseef <ar...@artnaseef.com>.
This is an interesting mix of needs.  Using message groups to ensure ordered
processing of messages while at least some of the messages take excessive
periods of time to process.

Can the slow-processing messages be separated from the message-groups?

Note the default message group handling uses a hash bucket of group
assignments to consumers, meaning multiple groups are assigned as a unit. 
So, assigning the slow messages to only one group will not prevent mixing
with fast messages (remember one consumer may be assigned multiple groups).

The -1 sequence on the group only takes effect as that message is dispatched
to the assigned owner (when it has prefetch space available), meaning it
goes to the same old owner as the message immediately before it, but then
new messages may go to a different owner.  So, actually, a higher prefetch
may be needed so that the -1 sequence message can be dispatched, but then it
will only affect messages that come after it, not those from before. 
Assigning a sequence number of -1 for the group on the slow messages would
do the trick - if combined with a prefect of 1.

Of course, if the fast and slow messages are in the same group, then the
fast messages need to wait for the slow ones to process.  That's the point
of message groups.

Another thought - is it possible eliminate the use of message groups adding
a message aggregator (camel) to collect all of the messages that require
sequential processing and feed them back out as a single message?




--
View this message in context: http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p4698769.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Message Groups and long running transactions

Posted by George K <gk...@gmail.com>.
Thanks Hiram, I am pretty sure I tried that, but since then I went with a
custom approach so I can't verify it now. If I ever do, ill post back.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p4698128.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Message Groups and long running transactions

Posted by Hiram Chirino <hi...@hiramchirino.com>.
Hi George,

If your consumer uses low prefetch (like 1), you should get the same effect.

On Thu, Feb 5, 2015 at 7:01 PM, George K <gk...@gmail.com> wrote:
> Hi,
> If a solution has been identified on how to ensure that long running
> transactions don't cause delays for messages from other message groups
> please share.
>
> Basically it would work if broker only assigned messages from a *new*
> message group to a free consumer and never to a consumer that is busy
> processing something already. So only messages form already assigned group
> can be assigned prior to dispatch.
>
> Without this working load balancing pretty much is broken for systems that
> can encounter one off long running transactions.
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p4691136.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.



-- 
Hiram Chirino
Engineering | Red Hat, Inc.
hchirino@redhat.com | fusesource.com | redhat.com
skype: hiramchirino | twitter: @hiramchirino

Re: Message Groups and long running transactions

Posted by George K <gk...@gmail.com>.
Hi,
If a solution has been identified on how to ensure that long running
transactions don't cause delays for messages from other message groups
please share.

Basically it would work if broker only assigned messages from a *new*
message group to a free consumer and never to a consumer that is busy
processing something already. So only messages form already assigned group
can be assigned prior to dispatch.

Without this working load balancing pretty much is broken for systems that
can encounter one off long running transactions.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p4691136.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Message Groups and long running transactions

Posted by Dejan Bosanac <de...@nighttale.net>.
Yes, also it'd be great to have rebalaning of message groups among consumers
(https://issues.apache.org/jira/browse/AMQ-2106). All contributions are
welcomed :)

Regards
-- 
Dejan Bosanac - http://twitter.com/dejanb
-----------------
The experts in open source integration and messaging - http://fusesource.com
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net

Connect at CamelOne <http://camelone.com/> May 24-26

The Open Source Integration Conference



On Mon, May 9, 2011 at 4:39 PM, rbolen <ri...@gxs.com> wrote:

> I've tested it.  It appears the broker does not release the group from the
> consumer until the consumer -1 sequence message is processed by the
> consumer.
>
> What would be really cool is if the broker could detect a slow consumer and
> free all the groups from that consumer except the current group for the
> long
> transaction.  Another cool thing would be a client API to control the
> message groups association.
>
> I guess this is all non-standard so developing an API around it could be
> tricky.
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p3509284.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>

Re: Message Groups and long running transactions

Posted by rbolen <ri...@gxs.com>.
I've tested it.  It appears the broker does not release the group from the
consumer until the consumer -1 sequence message is processed by the
consumer.

What would be really cool is if the broker could detect a slow consumer and
free all the groups from that consumer except the current group for the long
transaction.  Another cool thing would be a client API to control the
message groups association.

I guess this is all non-standard so developing an API around it could be
tricky.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p3509284.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Message Groups and long running transactions

Posted by Dejan Bosanac <de...@nighttale.net>.
It should, as the messages are pulled and immediately dispatched to
consumers. But be sure to test it out.

Regards
-- 
Dejan Bosanac - http://twitter.com/dejanb
-----------------
The experts in open source integration and messaging - http://fusesource.com
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net

Connect at CamelOne <http://camelone.com/> May 24-26

The Open Source Integration Conference



On Fri, May 6, 2011 at 6:14 PM, rbolen <ri...@gxs.com> wrote:

> So if I set prefetch to 0, it should work?  i.e. the broker would
> immediately
> free the group from the consumer and his messages would go to a new
> consumer.
>
> man thx
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p3503243.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>

Re: Message Groups and long running transactions

Posted by rbolen <ri...@gxs.com>.
So if I set prefetch to 0, it should work?  i.e. the broker would immediately
free the group from the consumer and his messages would go to a new
consumer.

man thx

--
View this message in context: http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p3503243.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: Message Groups and long running transactions

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi,

the broker should process the message with -1 group id and release the
group. However, the problem you might have is that consumer is full doing a
long tx (as prefetch is 1) and in that case the message wouldn't be
processed until tx ends.


Regards
-- 
Dejan Bosanac - http://twitter.com/dejanb
-----------------
The experts in open source integration and messaging - http://fusesource.com
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net

Connect at CamelOne <http://camelone.com/> May 24-26

The Open Source Integration Conference



On Thu, May 5, 2011 at 10:59 PM, rbolen <ri...@gxs.com> wrote:

> We are looking at using message groups (activeMQ V5.5.0).  We are using an
> external broker also.  We have a use case where a consumer could be
> processing a long running transaction (multiple hours).
>
> My understanding of message groups is that a group is initially assigned to
> a specific consumer and then stays on that consumer until a message comes
> through with a -1 group sequence.  But in the case where a consumer is
> processing a long transaction for group A and the consumer also has group B
> assigned, messages for group B will have to wait for the long running group
> A message to complete.  We'd like to avoid this.
>
> Is it true that even if we send a group B message with sequence -1, it
> would
> only be processed after the long running transaction is complete anyway,
> thus defeating the purpose of the -1 sequence?  Or does the broker process
> it while the work on the client is being done thus freeing Group B to run
> on
> another consumer.  (We're using prefetch of 1 but we could set it to 0 if
> it
> would help.)
>
> Is there a recommended way to avoid this situation?  Detect the large
> payload and pre-emptively send -1 messages?  Create a new consumer
> dynamically for large loads?
>
> Thanks,
> Rich
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Message-Groups-and-long-running-transactions-tp3499325p3499325.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>