问题
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