Effect of ExchangePattern.InOnly on mq endpoint

拈花ヽ惹草 提交于 2020-01-05 06:56:08

问题


I have my route defined as

from("jetty:http://0.0.0.0:xxxx/abc").to("activemq:queue:queue1").setExchangePattern(ExchangePattern.InOnly);

I understand that this route drops a meessage to the broker and does not wait for the message consumer to consume it. I want to understand the impact of ExchangePattern.InOnly with respect to broker accepting message. I have persistence enabled on the broker. Does the above route ensure that it is persisted before the exchange is completed.


回答1:


You need to set the MEP before sending to the JMS queue. An alternative is to tell just to use InOnly when sending to the Queue. So you can do

from("jetty:http://0.0.0.0:xxxx/abc")
  .setExchangePattern(ExchangePattern.InOnly)
  .to("activemq:queue:queue1");

Or

from("jetty:http://0.0.0.0:xxxx/abc")
  .to(ExchangePattern.InOnly, "activemq:queue:queue1");

You can see more details at the Camel web site for the event and request-reply message EIPs

  • http://camel.apache.org/event-message.html
  • http://camel.apache.org/request-reply.html

And yes if you have persistent enabled on the broker, then it will store the message in a persistent store, when it receives the message, and before the broker send back an ACK to the sender (which in this example is Camel). And Camel will the continue routing after sending to the broker, and reach the end of hte route, and to return a response for Jetty. You may consider setting some empty response to use, eg:

from("jetty:http://0.0.0.0:xxxx/abc")
  .to(ExchangePattern.InOnly, "activemq:queue:queue1")
  .transform().constant("OK");


来源:https://stackoverflow.com/questions/15104260/effect-of-exchangepattern-inonly-on-mq-endpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!