You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by marco-dak <bu...@dakosy.de> on 2016/02/23 10:54:08 UTC

Message processed in wrong order

Hi,

I encounter an issue with Camel (2.13) and ActiveMQ (5.11.1) on JBoss EAP
(6.1) where messages are processed in wrong order. It only occurs if there
are a lot of messages send to a single queue.

I can reproduce it with a very simple example:

<route id="sendRoute">
        <c:from uri="activemq:queue:START-QUEUE" />
        <loop>
                <constant>1000</constant>

                <c:setHeader headerName="testHeader">
                        <simple>${property.CamelLoopIndex}</simple>
                </c:setHeader>
                <c:to uri="activemq:queue:DESTINATION-QUEUE"
pattern="InOnly"/>
                       
                <c:setHeader headerName="testHeader">
                        <simple>${property.CamelLoopIndex}a</simple>
                </c:setHeader>   
                <c:to uri="activemq:queue:DESTINATION-QUEUE"
pattern="InOnly"/>
        </loop>
</route>

<route id="destinationRoute">
        <c:from uri="activemq:queue:DESTINATION-QUEUE" />
        <c:log message="$simple{header.testHeader}" />
</route>

I'm starting this example by sending a message to activemq:queue:START-QUEUE
via ActiveMQ console.

In the first route I set the loop index to the header and send it to
activemq:queue:DESTINATION-QUEUE. Than I overwrite the header by adding an
"a" to the loop index and send it also to activemq:queue:DESTINATION-QUEUE.

In the second route there is only one consumer reading messages from
activemq:queue:DESTINATION-QUEUE and log the header value that was set in
the first route.

I assumed that for the same index (e.g. 671) it should always logged before
the index containing the "a" (e.g. 671a), but it doesn't.

For example I got the following output in log:
08:17:49,666 INFO  [destinationRoute] 671a
...
08:17:52,385 INFO  [destinationRoute] 671

Why are the messages processed in the wrong order?
Is there any way to make sure that messages (for the same index) are always
procssed in the correct order?

If it not occurs if you run this example the first time, run it again.
Mostly it occurs after the first 200 messages are procssed in the correct
order.

It's very important for this project to process the messages send to
activemq:queue:DESTINATION-QUEUE in the correct order.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Message-processed-in-wrong-order-tp4708058.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Message processed in wrong order

Posted by artnaseef <ar...@artnaseef.com>.
Hey Tim - even if the messages are sent asynchronously from the client, their
order should be maintained.  In fact, the message is sent to the transport
entirely.  The big difference is that the client code does not wait for the
server to send back a response indicating that it successfully received the
message.

Take a look as ActiveMQConnection.java, asyncSendPacket().



--
View this message in context: http://activemq.2283324.n4.nabble.com/Message-processed-in-wrong-order-tp4708058p4708445.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Message processed in wrong order

Posted by Tim Bain <tb...@alumni.duke.edu>.
Are the messages persistent?  If not, maybe async sends (
http://activemq.apache.org/async-sends.html) are allowing messages to be
sent in parallel on separate threads.

Does the behavior change if you make your from endpoint transacted
(?transacted=true), which forces synchronous sends by producers?
On Feb 25, 2016 9:29 PM, "artnaseef" <ar...@artnaseef.com> wrote:

> How many producers are being used by the application?
>
> To determine the answer to that question, you need to look at the
> connection
> settings used by the "activemq" component and related beans.
>
> It is also possible to check the same by looking at Message IDs as each
> message ID contains the ID of the producer that created the message.
>
> If there is more than 1 producer, message order has no guarantees across
> multiple producers.
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Message-processed-in-wrong-order-tp4708058p4708433.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Re: Message processed in wrong order

Posted by artnaseef <ar...@artnaseef.com>.
How many producers are being used by the application?

To determine the answer to that question, you need to look at the connection
settings used by the "activemq" component and related beans.

It is also possible to check the same by looking at Message IDs as each
message ID contains the ID of the producer that created the message.

If there is more than 1 producer, message order has no guarantees across
multiple producers.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Message-processed-in-wrong-order-tp4708058p4708433.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.