简体   繁体   中英

JMS listener using thread pool

I'm using a Spring project where I have an implementation of JMS Event listener to process messages from a queue.

To be precise, I'm using a SQS (AWS) queue.

All works fine.

My point is this: I not configured anything about the concurrency but I would like to have more threads as listener to increase the performances (speed) about the messages processing from the queue.

I'm thinking about the possibility to configure a ThreadPool (TaskExecutor) and adding the annotation @Async on my methods about the message processing.

So, I will have a onMessage method into my listener where, after message validation I will call this async methods.

Is this a good practice? Will I have some issues using this approach?

I'm looking on the web for this and I see that I's possible to configure directly the concurrency value on the listener.

I'm very confusing there are a lot of possible ways to have this and I'm not able to understand the best approach.

Are these equivalent solutions?

不要使用@Async - 只需增加侦听器容器的并发性,spring-jms 会自动为您处理。

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