开发者

Spring Topic Subscriber thread-pooling

开发者 https://www.devze.com 2023-03-02 17:51 出处:网络
I have been skimming forums and websites for a few days now about how to thread-pool a spring JMS subscriber with very little luck.When using a queue with the jms:listener-container there is a concurr

I have been skimming forums and websites for a few days now about how to thread-pool a spring JMS subscriber with very little luck. When using a queue with the jms:listener-container there is a concurrency property, however, with a topic it states to keep concurrency at 1. Given that, what are my options for thread-pooling a topic subscriber?

I started out with the MessageListener route with the implementation of onMessage with:

    <bean id="messageListener" class="com.app.mdp.Receiver"/>
    <jms:listener-container container-type="default"
        connection-factory="connectionFactory" acknowledge="auto" concurrency="1"
        destination-type="topic" prefetch="1">
        <jms:listener destination="topTopic" ref="messageListener"
            method="onMessage" subscription="ASub" />
    </jms:listener-container>

    <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="jms/jms-top-notx" />
    </bean>

The problem with this is I get at most one thread receiving data from JMS at a time.

I then attempted to use a task executor with config:

<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
  <property name="corePoolSize" value="10" />
  <property name="maxPoolSize" value="20" />
  <property name="queueCapacity" value="0" />
</bean> 

..but it seems to require concurrency to be of a greater value in the jms:listener-container setup (unless I am misunderstanding). Still I only received one thread at a time.

I am at a bit of a loss and starting to think that spring does not have functiona开发者_运维问答lity to support multiple threads when subscribing to JMS topic data. If that is the case my options seem to be:

  • implement my own thread pool. schedule subscriber->loop through jmsTmplate.receive() data->pass each message to a predefined thread
  • revert back to EJBs (which I don't want to do)
  • something else I have yet to think of

Any help would be greatly appreciated.


Are you using Websphere for the JMS . If yes then there is a configuration in Websphere where you can configure the number of connection and session's you can make for the application at a time . Suppose if you have 10 sessions and 10 connections then you will have 100 connection(channels)open to MQ server . refer this link : http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/umj_sesspoolset.html

0

精彩评论

暂无评论...
验证码 换一张
取 消