Set TTL Apache Camel JAva DSL

后端 未结 2 1288
闹比i
闹比i 2021-01-28 01:16

How do you set the TTL for a message when using Java DSL?

I have something like this:

...
from (\"timer:something?delay=3000&period=15000\")
   ...
          


        
相关标签:
2条回答
  • 2021-01-28 01:45

    I ended up setting the JMSExpiration header field of the messages being created similar to the following

    .setHeader("JMSExpiration", constant(System.currentTimeMillis() + 1000))
    

    We are using Apache ActiveMQ 5.7.

    0 讨论(0)
  • 2021-01-28 01:59

    I assume TTL means Time to Live.

    In Camel this is component specific how they deal with this. Some components support this, and others do not.

    You should check the documentation for the component you use, what it supports.

    If you use JMS component then it has the timeToLive option as documented: http://camel.apache.org/jms

    And mind about the problem with "client and server clock's can be out of sync". There is some details on the Camel JMS page. Some message brokers has ways to sync the clocks, such as Apache ActiveMQ with its timestamp plugin: http://activemq.apache.org/timestampplugin.html

    0 讨论(0)
提交回复
热议问题