4

I am trying to implement a message producer behind a REST interface. The message producer uses the request/reply pattern. When reading the documentation for the Camel producer it is noted that only one producer should be created per application.

Is the producer thread safe so that I can call the send method from multiple threads? Will it work properly when several concurrent requests are waiting for their related replies? How would it be best implemented using Spring, Tomcat and Jersey?

Thank you.

4

1 回答 1

4

Yes both the producer and consumer template in Apache Camel is thread safe.

And yeah the request/reply works properly. How it is implemented is a mix between the Camel routing engine, and the components that are being used.

eg REST and JMS works a bit differently. Where JMS will use separate message queues to pickup replies, which has a JMSCorrelationID that is used for correlating reply messages.

Where as REST is usually a sync call due the sync nature of HTTP. But it depends on the underlying component, as some supports async communication on the http client such as camel-jetty, camel-ahc etc.

于 2013-03-31T06:35:26.540 回答