Quantcast

Messenger does not respect order after redelivery

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Messenger does not respect order after redelivery

Fabian Gonzalez
Hello,

This is my  first message so greetings for all.
I am facing a situation  where activemq seems not to respect the order for
dispatched messages when a redilevery is needed using activemq-client
5.14.3.

I am sending 60 messages to a queue with a single consumer, and I've
noticed that sometimes when a relivery of the message is needed, as a
consequence of rollback, another message from those 60 message is served
before the redelivered message. There is no maxRedelivery set.

What I notice debugging ActiveMQMessageConsumer is that the following
behaviour may occur:

- The 60 messages are dispatched in order in:

ActiveMQMessageConsumer:1376:

    @Override
    public void dispatch(MessageDispatch md) {
        MessageListener listener = this.messageListener.get();
        try {
            clearMessagesInProgress();
            ...

unconsumedMessage is running so the message is sent to the listener.

- a rollback is performed and the message is redelivered (with a default
delay):

ActiveMQMessageConsumer:1305:

                        if (redeliveryDelay > 0 &&
!unconsumedMessages.isClosed()) {
                            // Start up the delivery again a little later.
                            session.getScheduler().executeAfterDelay(new
Runnable() {
                                @Override
                                public void run() {
                                    try {
                                        if (started.get()) {
                                            start();
                                        }
                                    } catch (JMSException e) {

session.connection.onAsyncException(e);
                                    }
                                }
                            }, redeliveryDelay);
                        } else {
                            start();
                        }

Periodically, the messages enqueued in the session are attempted to be
consumed (as the unconsumedMessages from the consumer is not running they
are not sent to the listener to be consumed and they are enqueued as
unconsumedMessages).
But if the thread scheduled from redelivery is started when the iteration
from the unconsumed messages is being performed, the unconsumedMessages is
started in:

    public void start() throws JMSException {
        if (unconsumedMessages.isClosed()) {
            return;
        }
        started.set(true);
        unconsumedMessages.start();
        session.executor.wakeup();
    }

and the message that is being considered from session (in the other thread)
is sent to the listener before the redelivered message, which may be an
error in order.

Is this the expected behaviour? I expected that the order was mantained in
this cases.

Thanks in advance for your help and clarification
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Messenger does not respect order after redelivery

Tim Bain
I'm not an expert on the dispatch code, but this isn't the behavior I'd
expect to see, so please submit a bug in JIRA for it so we can get someone
who knows that code well can fix it (or explain why this is the intended
behavior, if that's the case).

Tim

On Tue, Apr 11, 2017 at 1:15 PM, Fabian Gonzalez <
[hidden email]> wrote:

> Hello,
>
> This is my  first message so greetings for all.
> I am facing a situation  where activemq seems not to respect the order for
> dispatched messages when a redilevery is needed using activemq-client
> 5.14.3.
>
> I am sending 60 messages to a queue with a single consumer, and I've
> noticed that sometimes when a relivery of the message is needed, as a
> consequence of rollback, another message from those 60 message is served
> before the redelivered message. There is no maxRedelivery set.
>
> What I notice debugging ActiveMQMessageConsumer is that the following
> behaviour may occur:
>
> - The 60 messages are dispatched in order in:
>
> ActiveMQMessageConsumer:1376:
>
>     @Override
>     public void dispatch(MessageDispatch md) {
>         MessageListener listener = this.messageListener.get();
>         try {
>             clearMessagesInProgress();
>             ...
>
> unconsumedMessage is running so the message is sent to the listener.
>
> - a rollback is performed and the message is redelivered (with a default
> delay):
>
> ActiveMQMessageConsumer:1305:
>
>                         if (redeliveryDelay > 0 &&
> !unconsumedMessages.isClosed()) {
>                             // Start up the delivery again a little later.
>                             session.getScheduler().executeAfterDelay(new
> Runnable() {
>                                 @Override
>                                 public void run() {
>                                     try {
>                                         if (started.get()) {
>                                             start();
>                                         }
>                                     } catch (JMSException e) {
>
> session.connection.onAsyncException(e);
>                                     }
>                                 }
>                             }, redeliveryDelay);
>                         } else {
>                             start();
>                         }
>
> Periodically, the messages enqueued in the session are attempted to be
> consumed (as the unconsumedMessages from the consumer is not running they
> are not sent to the listener to be consumed and they are enqueued as
> unconsumedMessages).
> But if the thread scheduled from redelivery is started when the iteration
> from the unconsumed messages is being performed, the unconsumedMessages is
> started in:
>
>     public void start() throws JMSException {
>         if (unconsumedMessages.isClosed()) {
>             return;
>         }
>         started.set(true);
>         unconsumedMessages.start();
>         session.executor.wakeup();
>     }
>
> and the message that is being considered from session (in the other thread)
> is sent to the listener before the redelivered message, which may be an
> error in order.
>
> Is this the expected behaviour? I expected that the order was mantained in
> this cases.
>
> Thanks in advance for your help and clarification
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Messenger does not respect order after redelivery

vas u
In reply to this post by Fabian Gonzalez
please unsubscribe me.



On Tue, Apr 11, 2017 at 3:15 PM, Fabian Gonzalez <
[hidden email]> wrote:

> Hello,
>
> This is my  first message so greetings for all.
> I am facing a situation  where activemq seems not to respect the order for
> dispatched messages when a redilevery is needed using activemq-client
> 5.14.3.
>
> I am sending 60 messages to a queue with a single consumer, and I've
> noticed that sometimes when a relivery of the message is needed, as a
> consequence of rollback, another message from those 60 message is served
> before the redelivered message. There is no maxRedelivery set.
>
> What I notice debugging ActiveMQMessageConsumer is that the following
> behaviour may occur:
>
> - The 60 messages are dispatched in order in:
>
> ActiveMQMessageConsumer:1376:
>
>     @Override
>     public void dispatch(MessageDispatch md) {
>         MessageListener listener = this.messageListener.get();
>         try {
>             clearMessagesInProgress();
>             ...
>
> unconsumedMessage is running so the message is sent to the listener.
>
> - a rollback is performed and the message is redelivered (with a default
> delay):
>
> ActiveMQMessageConsumer:1305:
>
>                         if (redeliveryDelay > 0 &&
> !unconsumedMessages.isClosed()) {
>                             // Start up the delivery again a little later.
>                             session.getScheduler().executeAfterDelay(new
> Runnable() {
>                                 @Override
>                                 public void run() {
>                                     try {
>                                         if (started.get()) {
>                                             start();
>                                         }
>                                     } catch (JMSException e) {
>
> session.connection.onAsyncException(e);
>                                     }
>                                 }
>                             }, redeliveryDelay);
>                         } else {
>                             start();
>                         }
>
> Periodically, the messages enqueued in the session are attempted to be
> consumed (as the unconsumedMessages from the consumer is not running they
> are not sent to the listener to be consumed and they are enqueued as
> unconsumedMessages).
> But if the thread scheduled from redelivery is started when the iteration
> from the unconsumed messages is being performed, the unconsumedMessages is
> started in:
>
>     public void start() throws JMSException {
>         if (unconsumedMessages.isClosed()) {
>             return;
>         }
>         started.set(true);
>         unconsumedMessages.start();
>         session.executor.wakeup();
>     }
>
> and the message that is being considered from session (in the other thread)
> is sent to the listener before the redelivered message, which may be an
> error in order.
>
> Is this the expected behaviour? I expected that the order was mantained in
> this cases.
>
> Thanks in advance for your help and clarification
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Messenger does not respect order after redelivery

Tim Bain
You have to unsubscribe yourself. To unsubscribe, send a short email to
[hidden email].

On Apr 19, 2017 3:51 AM, "vas u" <[hidden email]> wrote:

> please unsubscribe me.
>
>
>
> On Tue, Apr 11, 2017 at 3:15 PM, Fabian Gonzalez <
> [hidden email]> wrote:
>
> > Hello,
> >
> > This is my  first message so greetings for all.
> > I am facing a situation  where activemq seems not to respect the order
> for
> > dispatched messages when a redilevery is needed using activemq-client
> > 5.14.3.
> >
> > I am sending 60 messages to a queue with a single consumer, and I've
> > noticed that sometimes when a relivery of the message is needed, as a
> > consequence of rollback, another message from those 60 message is served
> > before the redelivered message. There is no maxRedelivery set.
> >
> > What I notice debugging ActiveMQMessageConsumer is that the following
> > behaviour may occur:
> >
> > - The 60 messages are dispatched in order in:
> >
> > ActiveMQMessageConsumer:1376:
> >
> >     @Override
> >     public void dispatch(MessageDispatch md) {
> >         MessageListener listener = this.messageListener.get();
> >         try {
> >             clearMessagesInProgress();
> >             ...
> >
> > unconsumedMessage is running so the message is sent to the listener.
> >
> > - a rollback is performed and the message is redelivered (with a default
> > delay):
> >
> > ActiveMQMessageConsumer:1305:
> >
> >                         if (redeliveryDelay > 0 &&
> > !unconsumedMessages.isClosed()) {
> >                             // Start up the delivery again a little
> later.
> >                             session.getScheduler().executeAfterDelay(new
> > Runnable() {
> >                                 @Override
> >                                 public void run() {
> >                                     try {
> >                                         if (started.get()) {
> >                                             start();
> >                                         }
> >                                     } catch (JMSException e) {
> >
> > session.connection.onAsyncException(e);
> >                                     }
> >                                 }
> >                             }, redeliveryDelay);
> >                         } else {
> >                             start();
> >                         }
> >
> > Periodically, the messages enqueued in the session are attempted to be
> > consumed (as the unconsumedMessages from the consumer is not running they
> > are not sent to the listener to be consumed and they are enqueued as
> > unconsumedMessages).
> > But if the thread scheduled from redelivery is started when the iteration
> > from the unconsumed messages is being performed, the unconsumedMessages
> is
> > started in:
> >
> >     public void start() throws JMSException {
> >         if (unconsumedMessages.isClosed()) {
> >             return;
> >         }
> >         started.set(true);
> >         unconsumedMessages.start();
> >         session.executor.wakeup();
> >     }
> >
> > and the message that is being considered from session (in the other
> thread)
> > is sent to the listener before the redelivered message, which may be an
> > error in order.
> >
> > Is this the expected behaviour? I expected that the order was mantained
> in
> > this cases.
> >
> > Thanks in advance for your help and clarification
> >
>
Loading...