package com.hai.util;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.TextMessage;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;
/**
* JMS消费者
* 消息题的内容定义
* 消息对象 接收消息对象后: 接收到的消息体* <p>
*/
public class Consumer {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("初始化消息消费者");
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext-mq.xml");
JmsTemplate template = (JmsTemplate) applicationContext.getBean("jmsTemplate");
Destination destination = (Destination) applicationContext.getBean("destination");
while (true) {
TextMessage txtmsg = (TextMessage) template.receive(destination);
try {
if (null != txtmsg){
System.out.println("手动收到消息内容为: " + txtmsg.getText());
}else{
break;
}
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
activemqdemo20150228.rar (34个子文件)
activeMqProvider
.project 568B
pom.xml 3KB
target
test-classes
maven-archiver
pom.properties 131B
surefire
maven-status
maven-compiler-plugin
compile
default-compile
createdFiles.lst 60B
inputFiles.lst 79B
testCompile
default-testCompile
inputFiles.lst 0B
activeMqProvider-0.0.1-SNAPSHOT.jar 6KB
generated-sources
annotations
classes
applicationContext-mq.xml 3KB
META-INF
maven
activeMqProvider
activeMqProvider
pom.xml 3KB
pom.properties 251B
MANIFEST.MF 109B
com
hai
util
Producers$1.class 828B
Producers.class 1KB
.settings
org.eclipse.core.resources.prefs 211B
org.eclipse.jdt.core.prefs 664B
org.eclipse.m2e.core.prefs 90B
src
test
resources
java
main
resources
applicationContext-mq.xml 3KB
java
com
hai
util
Producers.java 1KB
.classpath 809B
activeMqConsumer
.project 568B
pom.xml 3KB
target
test-classes
classes
applicationContext-mq.xml 3KB
META-INF
maven
activeMqConsumer
activeMqConsumer
pom.xml 3KB
pom.properties 251B
MANIFEST.MF 109B
com
hai
listener
ConsumerListener.class 1KB
util
Consumer.class 2KB
.settings
org.eclipse.core.resources.prefs 191B
org.eclipse.jdt.core.prefs 243B
org.eclipse.m2e.core.prefs 90B
src
test
resources
java
main
resources
applicationContext-mq.xml 3KB
java
com
hai
listener
ConsumerListener.java 761B
util
Consumer.java 1KB
.classpath 1KB
共 34 条
- 1
liolioyeye
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- J185-VB一款SOT23封装P-Channel场效应MOS管
- 计算整数各位数字之和,利用java代码实现
- J185-T2B-VB一款SOT23封装P-Channel场效应MOS管
- map20231226Kalmanfilter.ipynb
- J185-T1B-VB一款SOT23封装P-Channel场效应MOS管
- ASME Y14.5-2018 尺寸与公差标注 中文版
- J185-T1B-A-VB一款SOT23封装P-Channel场效应MOS管
- J168-VB一款SOT23封装P-Channel场效应MOS管
- J166-VB一款SOT23封装P-Channel场效应MOS管
- i2c测试程序-linux-如何调试i2c.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页