简体   繁体   中英

Spring Integration JMS Threadsafe

I'm pretty new to Spring Integration and still trying to get my head around it. Right now I'm just trying to understand if the example I've found here is actually safe across multiple threads:

https://github.com/spring-projects/spring-integration-samples/blob/master/basic/jms/src/test/java/org/springframework/integration/samples/jms/ChannelAdapterDemoTest.java

My use case is as follows:

  • Send request to queue with JMS Reply-to as a temporary queue
  • Wait for response to be received on the temporary queue
  • Need this to happen synchronously within a method -- I don't want to split it up and make it asynchronous across several methods

Will the above example work for this? If not, am I barking up the wrong tree?

Thanks in advance.

That sample is pretty simple; it just sends the message to stdout so, yes, it's perfectly thread safe.

For the request/reply scenario you are talking about, you need to use a <gateway/> - see the other example in that sample project . In that case, you can see that the message is handled by 'demoBean' which, again, is perfectly thread safe.

For a real application, the thread-safetyness depends on the code in the services invoked by the flow receiving the message.

If you wish, you can use Spring Integration on the client side too (with an outbound gateway).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM