Note that there are some explanatory texts on larger screens.

plurals
  1. POJMS and ThreadPool problem?
    text
    copied!<p>I want that jms receives a message when one thread has handled a message (threadPool submits a callable). The messages are received by a master thread. Which way is better below:</p> <p>I use spring 3.0.5 :</p> <pre><code>ApplicationContext context = new ClassPathXmlApplicationContext( "application-context.xml"); jmsTemplate = (JmsTemplate) context.getBean("jmsTemplate"); destination = (Destination) context.getBean("destination"); _log4j.debug("ThreadSize in xml\t" + appConfig.getThumbCreatorThreadSize()); </code></pre> <p>in master thread Way 1: </p> <pre><code>while (countFlag &lt; 0) { try { TextMessage msg = (TextMessage) jmsTemplate .receive(destination); // prehandle ,then give to sub workers. if (msg != null) { _log4j.debug("JMSMessageID:\t" + msg.getJMSMessageID() + "\t" + msg.getText()); IConsumer thumbConsumerImpl = null; thumbConsumerImpl = new ThumbConsumerTaskImpl(msg); Future&lt;List&lt;ThumbCreatorInfo&gt;&gt; result = threadPool .submit((Callable&lt;List&lt;ThumbCreatorInfo&gt;&gt;) thumbConsumerImpl); } } catch (IllegalArgumentException e) { _log4j.warn(e.getMessage(), e); } catch (JMSException e) { _log4j.error("Please check the queue server!JMSException!", e); } catch (Exception e) { _log4j.error("", e); } } </code></pre> <p>in master thread Way 2:</p> <pre><code> TextMessage msg = (TextMessage) jmsTemplate.receive(destination); do { try { // prehandle ,then give to sub workers. if (msg != null) { _log4j.debug("JMSMessageID:\t" + msg.getJMSMessageID() + "\t" + msg.getText()); IConsumer thumbConsumerImpl = null; thumbConsumerImpl = new ThumbConsumerTaskImpl(msg); Future&lt;List&lt;ThumbCreatorInfo&gt;&gt; result = threadPool .submit((Callable&lt;List&lt;ThumbCreatorInfo&gt;&gt;) thumbConsumerImpl); } msg = (TextMessage) jmsTemplate.receive(destination); } catch (IllegalArgumentException e) { _log4j.warn(e.getMessage(), e); } catch (JMSException e) { _log4j.error("Please check the queue server!JMSException!", e); } catch (Exception e) { _log4j.error("", e); } } while (countFlag &lt; 0); </code></pre>
 

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