This commit is contained in:
shuzheng 2016-12-08 18:06:03 +08:00
parent a646121b1a
commit 26a54553eb
2 changed files with 7 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -30,8 +31,8 @@ public class MessageListener extends MessageListenerAdapter {
@Autowired
UserService userService;
@JmsListener(containerFactory = "connectionFactory", destination = "defaultQueueDestination")
public void processOrder(final Message message) {
@JmsListener(destination="defaultQueueDestination",concurrency="5-10")
public void processOrder(final Message message, Session session) {
// 使用线程池多线程处理
threadPoolTaskExecutor.execute(new Runnable() {
public void run() {

View File

@ -48,6 +48,10 @@
<!--<property name="messageListener" ref="defaultQueueMessageListener"/>-->
<!--&lt;!&ndash;<property name="concurrency" value="4-10"/>&ndash;&gt;-->
<!--</bean>-->
<bean id="jmsListenerContainerFactory" class="org.springframework.jms.config.DefaultJmsListenerContainerFactory">
<property name="connectionFactory" ref="connectionFactory"/>
</bean>
<jms:annotation-driven/>
</beans>