写点什么

Spring AMQP 1.0 GA 发布了

  • 2012-02-05
  • 本文字数:1491 字

    阅读完需:约 5 分钟

近日,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

2012-02-05 23:434061
用户头像

发布了 88 篇内容, 共 272.4 次阅读, 收获喜欢 9 次。

关注

评论

发布
暂无评论
发现更多内容

KaiwuDB 受邀出席中国智能化油气管道与智慧管网技术交流大会

KaiwuDB

#数据库

OpenIM Bot: 用LLM构建企业专属的智能客服

AI Inception

AIGC ChatGPT LLM rag

30天拿下Rust之Trait

希望睿智

Trait 特征 rust语言

[ICLR2024]基于对比稀疏扰动技术的时间序列解释框架ContraLSP

阿里云大数据AI技术

机器学习 阿里云 Iclr

华为云IoT专家实践分享,开源如何改变物联网?

华为云开发者联盟

物联网 华为云 华为云IoT 华为云开发者联盟 企业号2024年5月PK榜

还能报名!风靡硅谷开发者的 Unstructured Data Meetup 即将登陆中国!

Zilliz

非结构化数据 Meetup Milvus Zilliz

API安全为什么如此难搞?

芯盾时代

网络安全 物联网 终端安全 网关 API网关

AI日报|“蚂蚁技术日”首次对外开放 ,AI创新应用齐亮相;家教费拜拜,小度推“AI老师”学习机

可信AI进展

#人工智能

软件测试学习笔记丨Selenium 键盘鼠标事件ActionChains

测试人

软件测试

特朗普竞选带火PoliFi,以Bitget为例

加密眼界

Hexo最新实战:(一)Hexo7.0+GitHub Pages博客搭建

北桥苏

Hexo GitHub Pages 博客

不好好干活,不是刘强东的“兄弟”,所以可以开除了

码哥字节

职场成长 京东

为你的应用程序增加AppIntent能力

珲少

华鲲振宇携手华为云时习知,探索数字化培训新路径

YG科技

Owinps静态IP代理:跨境电商的优选解决方案

阿Q说代码

C++中的AI编程助手添加

芯动大师

c++ 编程 语法

30天拿下Rust之泛型

希望睿智

泛型 泛型编程 rust语言

Ingress controller:Kubernetes 的瑞士军刀

NGINX开源社区

Kubernetes pod api 网关 Ingress Controller 负载均衡器

OpenHarmony XTS认证分享

Laval小助手

Grubtech融资1500万美元

财见

markdown转思维导图!这2个格式转换工具一定要知道!

彭宏豪95

markdown 思维导图 在线白板 格式转换 AIGC

华为ICT大赛拿了奖,可以进华为吗?

YG科技

Spring AMQP 1.0 GA发布了_Java_Bienvenido David_InfoQ精选文章