0

I use apache camel with activemq and camel-http, after the message is sent to the endpoint and the request fails, I still lose the message from the queue. It is necessary that the message is not lost if the request failed. How can I do this?

<route>
<from uri="activemq://db_record_rows"/>
<to uri="http://localhost:3000" />
</route>
D. Batmanov
  • 39
  • 1
  • 8
  • 1
    Use transaction: [How Do I Make My JMS Endpoint Transactional?](https://camel.apache.org/how-do-i-make-my-jms-endpoint-transactional.html) – Bedla Jun 21 '19 at 11:43
  • @Bedla, Thanks, As far as I understood from the article, do I need to configure both endpoints("from" and "to")? – D. Batmanov Jun 24 '19 at 07:38
  • No, just consumer which starts transaction. – Bedla Jun 24 '19 at 16:58

1 Answers1

2

You can mark your consumer as transacted, so it will be handled by the transaction manager of your context.

from("activemq://db_record_rows?transacted=true")
.to("http://localhost:3000")
  • Thanks for the answer. I enabled this option for my queue, and I saw this behavior - the endpoint made several attempts to send a request(made only one request without option transacted), but then the message was still removed from the queue, I need to configure http-endpoint? – D. Batmanov Jun 24 '19 at 07:22
  • The message was not removed, it was probably just moved to DLQ after N of failed delivery attempts. Redelivery logic is configured as parameters in brokerUrl. Use eg this for infinite redelivery `jms.redeliveryPolicy.maximumRedeliveries=-1`.More details here: http://blog.nanthrax.net/?p=820 – Bedla Jun 24 '19 at 17:09