Spring AMQP 是基于 Spring 框架的 AMQP 消息解决方案,提供模板化的发送和接收消息的抽象层,提供基于消息驱动的 POJO。同时有 Java 和 .NET 的版本。
Spring AMQP (for Java) 1.4 M1 发布,此版本主要特性如下:
-
添加了基于注释的消息监听器 (
@RabbitListener),enabled with either@EnableRabbitor<rabbit:annotation-driven />(see below for an example). -
RabbitMessagingTemplate允许与RabbitMQusingspring-messagingMessage对象进行交互 -
添加了一个新工厂 bean,方便
RabbitConnectionFactory SSL 配置 -
Log4j Appender 现支持消息持久化配置
这里有在 POJO 服务使用新注释的示例:
public static class MyService { @RabbitListener(queues = "fooQ") public String capitalize(String foo) { return foo.toUpperCase(); }}@Configuration@EnableRabbitpublic static class EnableRabbitConfig { @Bean public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() { SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); factory.setConnectionFactory(rabbitConnectionFactory()); return factory; } @Bean public MyService myService() { return new MyService(); } // Rabbit infrastructure setup @Bean public ConnectionFactory rabbitConnectionFactory() { CachingConnectionFactory connectionFactory = new CachingConnectionFactory(); connectionFactory.setHost("localhost"); return connectionFactory; }}同时还发布了一个小版本: Spring AMQP 1.3.6 维护版本。
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-09/106243.htm
