Spring AMQP 1.0 GA发布了
来源:互联网 发布:自考本科 知乎 编辑:程序博客网 时间:2024/04/28 05:24
近日,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/rabbithttp://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsdhttp://www.springframework.org/schema/beanshttp://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.javaimport org.springframework.amqp.core.AmqpTemplate;...AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);amqpTemplate.convertAndSend("helloworld.queue", "Hello World");
Consumer.javaimport 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
- Spring AMQP 1.0 GA发布了
- Spring AMQP 1.0 GA发布了
- Spring for Apache Hadoop 1.0 GA 发布
- MyEclipse 6.5GA发布了
- myeclipse 7.0 GA 发布了
- ibatis3 发布 GA版了
- MyEclipse 4.1.1 GA发布了
- Groovy 1.5.6 GA 发布了!
- JDK 6 Update10(GA)终于发布了!
- Jboss 6.0GA 今天发布了
- Spring Integration 2.0 GA 版本发布!
- Spring框架4.0 GA版本发布
- Spring AMQP
- Spring Framework 3.2 GA版发布,Spring MVC焕然一新
- 新闻 | MariaDB Columnstore 1.0.6 GA发布
- MyEclipse 8.0 GA发布
- Ehcache 2.4 GA发布
- spring amqp股票交易(一)
- CSS优化需要注意的15个细节
- 从数据库中随机读出n条不重复的记录
- js技巧200
- jQuery学习笔记
- 启动Eclipse时,启不起来JVM terminated. Exit code=-1
- Spring AMQP 1.0 GA发布了
- C++读写XML文件(Libxml2库)
- xml 解析器
- 数据库用户别锁定了
- 《疯狂Android讲义》读书笔记
- GridView自定义分页类
- cscope 学习
- 嵌入式操作系统比较
- c++字符编码转换