<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> <property name="connectionFactory" ref="connectionFactory"></property> <property name="destination" ref="destination"></property> <property name="messageListener" ref="receiveMessageListener"></property> </bean> <bean id="receiveMessageListener" class="com.demo.jms.ReceiveMessageListener"></bean> <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL"> <value>tcp://localhost:61616</value> </property> </bean> <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory"> <ref bean="connectionFactory"/> </property> </bean> <bean id="destination" class="org.apache.activemq.command.ActiveMQQueue"> <constructor-arg index="0"> <value>HelloWorldQueue</value> </constructor-arg> </bean>
/*继承MessageListener 即可接收*/
public class ReceiveMessageListener implements MessageListener {
/*
* (non-Javadoc)
*
* @see javax.jms.MessageListener#onMessage(javax.jms.Message)
*/
private final static Logger logger = LoggerFactory
.getLogger(ReceiveMessageListener.class);
public void onMessage(Message message) {
if (message instanceof TextMessage) {
TextMessage text = (TextMessage) message;
try {
logger.info("Received message:" + text.getText());
String texts = text.getText();
new Add().sendMsg(texts);
} catch (JMSException e) {
e.printStackTrace();
}
}
}
相关推荐
Spring+JMS+ActiveMQ+Tomcat jar下载,在博客主页有实例,欢迎换看
基于Spring+JMS+ActiveMQ+Tomcat,我使用的版本情况如下所示:Spring 3.2.0,ActiveMQ 5.4.3,Tomcat 6.0.43。本例通过详细的说明和注释,实现消息服务的基本功能:发送与接收。Spring对JMS提供了很好的支持,可以...
Spring+JMS+消息处理
Spring + JMS + MQ Connection
基于Spring+JMS+ActiveMQ+Tomcat,做一个Spring4.1.0和ActiveMQ5.11.1整合实例,实现了Point-To-Point的异步队列消息和PUB/SUB(发布/订阅)模型,简单实例,不包含任何业务。
基于Spring+JMS+ActiveMQ+Tomcat,我使用的版本情况如下所示: •Spring 2.5 •ActiveMQ 5.4.0 •Tomcat 6.0.30 下面通过学习与配置,实现消息服务的基本功能:发送与接收。Spring对JMS提供了很好的支持,可以...
spring+jms+jta事务的消息发送和消息消费。 完整可正常运行例子,对JTA分布式事务的配置。 本例可以直接作为处理消息的项目,在此之上直接继续开发。
使用spring框架 实现消息传递 基于activemq
description="JMS Connection Factory" factory="org.apache.activemq.jndi.JNDIReferenceFactory" brokerURL="vm://shirdrnUrl" brokerName="MyActiveMQBroker"/> auth="Container" type="org.apache...
先上传一些照片,源码随后发布 .效果绝对震撼
NULL 博文链接:https://xkorey.iteye.com/blog/2114391
NULL 博文链接:https://xkorey.iteye.com/blog/2113910
NULL 博文链接:https://ihenu.iteye.com/blog/2270078
spring_jms是基于Maven+Spring+JMS+Active入门级实例.
Spring+JMS + Mysql这是一个很值得学习的例子,已经封装成了一个对象。。,Spring+JMS + Mysql
这是本人搭建的Spring框架,集成了Weblogic JMS,测试已经完成。现提供给大家下载学习。
Spring Boot + RWD + JMS/MQ