Hi,

I just started using Camel because apparently this is the way to go if
I need to reorder messages by their priority in the ActiveMQ.

Here is my setup:
Two producers (A and B) publish to OUT topic. Producer A sends
messages with priority 4, producer B with priority 9. There is one
subscriber that consumes messages from OUT. Ideally, all messages from
producer B are consumed almost immediately (they occur far les
frequently than those from A).

I configured a resequencer between OUT and OUT_ORDERED and configured
the subscriber to consume from the ordered topic. It didn't seem to
work, only B messages were consumed, all messages from A were dropped.
I configured camel this way:

context = new DefaultCamelContext();
context.addComponent("jms",
ActiveMQComponentactiveMQComponent("tcp://localhost:61616"));

context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
  from("jms:topic:" +
OUT_BUFFER).resequence(header("JMSPriority")).batch().timeout(TIMEOUT).allowDuplicates().reverse().to("jms:topic:"
+ OUT_ORDERED_BUFFER);
}

To ensure it's not the lower priority that caused messages to be
dropped, I gave producer A the same priority as B, ie. 9. The result
was the same, only B messages made it to the ordered topic. I made
this even simpler and configured the route simply as:

from("jms:topic:" + OUT_BUFFER).to("jms:topic:" + OUT_ORDERED_BUFFER);

Strangely enough, this didn't work either, only B messages were consumed.

I then realized that producer A sends plain Strings (using
producer.send(session.createObjectMessage(messageContent)), and
producer B sends custom serializable objects. That was the only
difference between these producers, so I created another custom
serializable class and made producer A publish its messages wrapped in
these objects. That worked, although very sluggishly, but both A and B
messages were consumed in the ordered buffer.

Finally my question, is there a reason why Camel drops String
messages? Is there something wrong in my setup perhaps?

Thanks for help!
Jakub

Reply via email to