I have a project that useed jms to keep messages between components. It worked well but I need to set up lots of queues and configuration is complicated. Now I try to use database MessageStore to take place of jms. It works well in single thread, but when I use multiple threads polling, each thread is very possible to get a same message and the result is a same message will be handled multiple times in different threads. The configuration is like this:
I wrote some codes to implement my own messageStore based on JDBCMessageStore, but it is not efficient to handle a mass amount of messages, like 500 messages in a queue at the same time. I hope spring can provide a new messageStore implementation besides JDBCMessageStore.class that can do with multiple threads.
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="10" />
<property name="maxPoolSize" value="20" />
<property name="queueCapacity" value="500" />
<jdbc:message-store id="messageStore" data-source="dataSource"/>
<si:queue capacity="500" message-store="messageStore"/>
<si:poller max-messages-per-poll="1" fixed-rate="2000" task-executor="taskExecutor">
In addtion, my application will have multiple instances running in different server to do the balance job. They have same database and messageStore configuration so that they are like multiple consumers to a queue. I will be very appreciated if you can consider this situation.