本文来源于我在InfoQ中文站翻译的文章,原文地址是:http://www.infoq.com/cn/news/2012/02/spring-amqp-1.0-ga近日,SpringSource(VMware下的一个部门)发布了Spring AMQP 1.0 GA(1.0.0.RELEASE)。Spring AMQP项目将Spring核心概念应用到了基于AMQP的消息解决方案的开发上,并且提供了Java与.NET两个版本。要想了解Spring AMQP与AMQP,请阅读文章“Introduction to SpringSource's Advanced Message Queuing Protocol Support”。
Spring AMQP提供了org.springframework.amqp.core.AmqpTemplate来发送与接收消息。AMQP模板实现支持发送与接收POJOs而非javax.jms.Message实例。他们还提供了一种方式来自定义用于编排对象的MessageConverter。Spring与JMS用户会发现JmsTemplate与新的AmqpTemplate之间的相似性。
下面的代码片段介绍了如何联合使用Spring AMQP与RabbitMQ处理同步消息。RabbitMQ是VMware的产品,并且是官方Spring AMQP示例中所用的默认AMQP实现。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/rabbit
http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<rabbit:connection-factory id="connectionFactory"/>
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory"/>
<rabbit:admin connection-factory="connectionFactory"/>
<rabbit:queue name="helloworld.queue"/>
</beans>
上述Spring配置xml引用了ConnectionFactory,创建了一个RabbitTemplate来访问消息broker,创建了一个RabbitAdmin来管理交换、查询与绑定,最后创建了队列。下面的Java代码片段用于发送与接收消息。
Producer.java
import org.springframework.amqp.core.AmqpTemplate;
...
AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);
amqpTemplate.convertAndSend("helloworld.queue", "Hello World");
Consumer.java
import org.springframework.amqp.core.AmqpTemplate;
...
AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);
System.out.println(amqpTemplate.receiveAndConvert("helloworld.queue"));
要想上手,请下载Spring AMQP for Java或是Spring AMQP for .NET。Spring AMQP for Java artifacts也位于SpringSource Maven仓库与Maven Central中。其依赖是spring-amqp、spring-core与spring-context。如果消息broker使用的是RabbitMQ,那么还要引入spring-rabbit。你还可以试一下位于GitHub上的Spring AMQP示例。这些示例都是基于Maven的项目,需要用到RabbitMQ与Erlang。请阅读与示例代码一同发布的readme.md文件以了解完整的构建命令。
对于Cloud Foundry用户来说,VMware还
发布了RabbitMQ on Cloud Foundry免费的公开Beta版。你可以使用AMQP连接RabbitMQ on Cloud Foundry,通过这些
示例可以帮助你快速上手。对于Spring Integration用户来说,版本2.1 M1提供了AMQP支持。
除了VMware的RabbitMQ外,其他基于AMQP面向消息的中间件还有Apache Qpid、Red Hat Enterprise MRG与StormMQ(托管)。iMatrix的OpenAMQ已经不再支持了,因此也没有成为一个选择。
要想了解关于Spring AMQP的更多信息,请查看Spring AMQP Reference for Java与Spring AMQP Reference for .NET参考页面。
查看英文原文:Spring AMQP 1.0 GA
分享到:
相关推荐
amqp1.0协议翻译
Spring AMQP API(Spring AMQP 开发文档).CHM 官网 Spring AMQP API。Spring AMQP 开发文档。
pack.ag/amqp pack.ag/amqp是Go的AMQP 1.0客户端实现。 注意:该项目不再处于积极开发中。 有关详细信息,请参见 。 与AMQP 0-9-1或0-10不兼容,后者是当今最常用的AMQP协议。 可以在上找到AMQP 1.0代理和其他AMQP ...
Nuklei AMQP 1.0 支持 AMQP 1.0 支持,包括编解码器享元和状态机
amqp 1.0协议通过了oasis审核,以后地位会越来越重要,这个文档就是从官方下载的那个文档,在csdn这里面上传一份方便大家寻找,最起码这里一搜就搜到,官网要是不熟悉的话要找半天
java rabbitmq spring springAMQP 代码包 project
Spring AMQP 1.5.3版本API
实现coap的java源码很棒的 AMQP 1.0 AMQP 1.0 资源的精选列表。 除非明确说明,本列表中的 AMQP 指的是 AMQP 1.0。...(AMQP) ...AMQP ...AMQP(工作草案)一起使用的消息地址定义基于标准文本的...云消息传递(队列、发布/订阅)
amqp高级消息队列协议v1.0
spring amqp 配置实现rabbitmq 路由
spring amqp资源下载
Spring AMQP 2 中文 参考手册 中文文档 中文文档都是由软件翻译,翻译内容未检查校对,文档内容仅供参考。
压缩包包含两部分,spring-amqp为java版的Spring AMQP的实现,spring-amqp-sample为补充版(也可作为快速入门的)
节点qpid 围绕 Apache Qpid 的 Node.js 本机包装器,特别是 AMQP 1.0 Proton C API用法您可以使用它与 AMQP 1.0 代理交换消息: // Sendingvar Messenger = require ( 'qpid' ) . proton . Messenger ;var m = new ...
一个使用springamqp实现的异步消息队列的股票系统,来自springamqp的官网,对于学习springamqp很有帮助。
Spring AMQP hello world
Spring AMQP 是基于 Spring 框架的 AMQP 消息解决方案,提供模板化的发送和接收消息的抽象层,提供基于消息驱动的 POJO。同时有 Java 和 .NET 的版本。
Spring AMQP 工作队列 源码
spring-amqp 相关jar , 最近在学spring amqp是时候找jar找了好长时间,现在找全了,在这分享给大家。
spring-amqp文档.zip