Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure I get what you're trying to do. If you're trying to have multiple messages processed concurrently, get away from the JmsTemplate and use a <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/jms/listener/DefaultMessageListenerContainer.html" rel="nofollow">DefaultMessageListenerContainer</a> with <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/jms/listener/DefaultMessageListenerContainer.html#setConcurrentConsumers%28int%29" rel="nofollow">concurrentConsumers</a>. Also available via the <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/jms.html#jms-namespace" rel="nofollow">JMS namespace</a>.</p> <p>For example, it seems that you could throw away all the code that you're showing in your question and use this instead:</p> <pre><code>&lt;jms:listener-container concurrency="10"&gt; &lt;jms:listener destination="some.queue" ref="fooService" method="handleNewFoo"/&gt; &lt;/jms:listener-container&gt; </code></pre> <p>That will automatically spawn up to 10 threads for concurrent message processing. When a message comes in, it will use one of the worker threads to call fooService.handleNewFoo(), where fooService is a bean in your Spring context.</p> <p><strong>Edit:</strong> I've created a sample project on github showing a basic Spring JMS setup. You can browse the source at <a href="https://github.com/zzantozz/testbed/tree/master/basic-spring-jms" rel="nofollow">https://github.com/zzantozz/testbed/tree/master/basic-spring-jms</a> or just clone and run it:</p> <pre><code>git clone git://github.com/zzantozz/testbed.git tmp cd tmp mvn compile exec:java -Dexec.mainClass=rds.jms.Main -pl basic-spring-jms </code></pre> <p>There's a main class that starts a JMS broker and starts Spring. When Spring starts, it inits a bean that begins sending JMS messages. There's also a Spring message listener as I described above that consumes messages and passes them to the same bean that produces messages, which prints them to stdout.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload