AMQ学习笔记 - 09. Spring-JmsTemplate之接收
概要
- 基本的接收
- 接收并转换
- 带有选择器的接收
- 选择接收并转换
1.基本的接收方法
| 接收 | 发送 |
|
|
Message message = jt.receive(DESTINATION_NAME); // convert
if (message != null && message instanceof TextMessage) {
String text = ( (TextMessage) message ).getText();
System.out.println(text);
}
2.接收并转换的方法
- public Object receiveAndConvert()
参考public Message receive(),在此基础上做了转换。 - public Object receiveAndConvert(Destination destination)
参考public Message receive(Destination destination),在此基础上做了转换。 - public Object receiveAndConvert(String destinationName)
参考public Message receive(String destinationName),在此基础上做了转换。
| convert |
Object data = jt.receiveAndConvert(DESTINATION_NAME);
if (data != null && data instanceof String) {
|
| usual |
Message message = jt.receive(DESTINATION_NAME); // convert |
3.带有选择器的接收方法
- public Message receiveSelected(String messageSelector)
参考public Message receive(),只是加入了筛选条件。 - public Message receiveSelected(Destination destination, String messageSelector)
参考public Message receive(Destination destination),只是加入了筛选条件 - public Message receiveSelected(String destinationName, String messageSelector)
参考public Message receive(String destinationName),只是加入了筛选条件
| 发送 |
String message = "a message for test convertProcessAndSend."; |
| 接收 |
jt.setReceiveTimeout(3*1000); // in milliseconds String messageSelector = "order = 1"; |
4.选择接收并转换的方法
- public Object receiveSelectedAndConvert(String messageSelector)
- public Object receiveSelectedAndConvert(Destination destination, String messageSelector)
- public Object receiveSelectedAndConvert(String destinationName, String messageSelector)
jt.setReceiveTimeout(3 * 1000); // in milliseconds String messageSelector = "order = 1";
Object data = jt.receiveSelectedAndConvert(DESTINATION_NAME, messageSelector); if (data != null && data instanceof String) {
System.out.println(data);
}
AMQ学习笔记 - 09. Spring-JmsTemplate之接收的更多相关文章
- Spring实战第八章学习笔记————使用Spring Web Flow
Spring实战第八章学习笔记----使用Spring Web Flow Spring Web Flow是一个Web框架,它适用于元素按规定流程运行的程序. 其实我们可以使用任何WEB框架写流程化的应 ...
- 机器学习实战(Machine Learning in Action)学习笔记————09.利用PCA简化数据
机器学习实战(Machine Learning in Action)学习笔记————09.利用PCA简化数据 关键字:PCA.主成分分析.降维作者:米仓山下时间:2018-11-15机器学习实战(Ma ...
- Spring实战第五章学习笔记————构建Spring Web应用程序
Spring实战第五章学习笔记----构建Spring Web应用程序 Spring MVC基于模型-视图-控制器(Model-View-Controller)模式实现,它能够构建像Spring框架那 ...
- C++ GUI Qt4学习笔记09
C++ GUI Qt4学习笔记09 qtc++ 本章介绍Qt中的拖放 拖放是一个应用程序内或者多个应用程序之间传递信息的一种直观的现代操作方式.除了剪贴板提供支持外,通常它还提供数据移动和复制的功 ...
- Spring 源码学习笔记10——Spring AOP
Spring 源码学习笔记10--Spring AOP 参考书籍<Spring技术内幕>Spring AOP的实现章节 书有点老,但是里面一些概念还是总结比较到位 源码基于Spring-a ...
- Spring 源码学习笔记11——Spring事务
Spring 源码学习笔记11--Spring事务 Spring事务是基于Spring Aop的扩展 AOP的知识参见<Spring 源码学习笔记10--Spring AOP> 图片参考了 ...
- AMQ学习笔记 - 12. Spring-JmsTemplate特性设置
概述 这是关于JmsTemplate的最后一篇总结,且只会介绍几个比较重要的特性. 消息的递送模式 在发送消息给时,可以告知这是持久化的消息,还是非持久化的消息.如果是非持久化的消息,broker会将 ...
- spring学习笔记(一) Spring概述
博主Spring学习笔记整理大部分内容来自Spring实战(第四版)这本书. 强烈建议新手购入或者需要电子书的留言. 在学习Spring之前,我们要了解这么几个问题:什么是Spring?Spring ...
- Java架构师之路 Spring学习笔记(一) Spring介绍
前言 这是一篇原创的Spring学习笔记.主要记录我学习Spring4.0的过程.本人有四年的Java Web开发经验,最近在面试中遇到面试官总会问一些简单但我不会的Java问题,让我觉得有必要重新审 ...
随机推荐
- 免费LInux主机资源
一.m-net.arbornet.org注冊 (1)telnet m-net.arbornet.org vista系统默认是关闭telnet的(由于不安全),须要开启.cmd->telnet(2 ...
- swift app中展示折线图, 饼状图, 柱状图等数据图表
github 下载Charts-master SDK,该SDK有多种可自定义的图表样式 lineChart 正弦余弦线图 LineChart (cubic lines) LineChart (grad ...
- 生成html的几种方案
方案1: /// <summary > /// 传入URL返回网页的html代码 /// </summary > /// <param name=&q ...
- 认清Linux中标准输入和标准输出的双重含义
按照惯例,UNIX系统shell使用文件描述符0与进程的标准输入(一般是键盘)相关联,文件描述符1与标准输出(一般是显示器)相关联,文件描述符2与标准出错输出(一般是显示器)相关联. 在依从POSIX ...
- 基于jQuery的宽屏可左右切换的焦点图插件
之前分享了很多实用的jQuery焦点图插件,大家可以看看.今天要继续为大家分享一款很不错的jQuery焦点图插件,它是宽屏展示的,而且有两个大气的按钮用来左右切换图片.效果图如下: 在线预览 源码 ...
- 转:《JavaScript—之对象参数的引用传递》
转自:博客园 Wayou http://www.cnblogs.com/Wayou/p/javascript_arguments_passing_with_reference.html 变量 1.Ja ...
- HTML常用标签和属性大全
html标签< <marquee>...</marquee>普通卷动 <marquee behavior=slide>...</marquee>滑 ...
- (Android学习系列)一,用按钮实现时间的显示
我们先用AndroidStudio新建一个项目,选择空白模板,然后像其中拖入两个Button,将他们的id分别命名为btDate(显示日期),btTime(显示时间),他的模板XML代码很简单 < ...
- LearnMVC5-AddAView
原创文章,转载必需注明出:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/learnmvc5-addaview/ 添加视图 在本章节 ...
- rpm build error: invalid predicate
rpm build error error message:/usr/lib/rpm/find-debuginfo.sh /usr/src/redhat/BUILD/RPMS find: invali ...