I'm trying to figure out if there is anyway i can impact the Consumer's message processing order when a message is rolled back on to the queue. I have some simple code below that helps me reproduce the issue. I am simply pushing messages onto a queue with different JMSXGroupIds in a certain order:
- "A1" (JMSXGroupId: 1)
- "B1" (JMSXGroupId: 2)
- "A2" (JMSXGroupId: 1)
- "C1" (JMSXGroupId: 3)
- "B2" (JMSXGroupId: 2)
The code makes A1 rollback (it initially retries the message 3 times) and it goes back on to the queue with a delay. However, the consumer then waits until it can pick up A1 again (after waiting the delayed amount of time), meaning B1 and C1 groups are blocked behind A1 and never get processed.
Ideally what i was hoping for is that when A1 is put back on the queue and told to wait, the Consumer would pick up B1 and C1... what i'm ultimately trying to do is stop one JMSXGroup blocking the others on a Consumer. Also, its probably worth adding that i need to keep message sequence order for A (A1,A2,A3...) and was hoping to do that by leaving them on the queue, rather than having to build some management solution for exceptions.
onException(Exception.class)
.log("Exception Caught !! ")
.redeliveryDelay("1000")
.maximumRedeliveries(3)
.handled(false)
.markRollbackOnly()
.log("log:output");
from("amq:queue:mailbox?concurrentConsumers=1")
.to(logEndpoint)
.process(exchange -> {
if(exchange.getIn().getBody(String.class).contains("A")) {
throw new Exception("Found A");
}
});
I am using a Java based Apache Camel micro-service with transacted routes. Nothing really out of the ordinary but i can supply more detail/configuration details if needed.
Thanks in advance