領先一步
VMware 提供培訓和認證,以加速您的進展。
了解更多我們很高興宣布 Spring AMQP 1.4 的候選版本 (Release Candidate) 已推出;正式版 (GA) 預計於 11 月初發布。
首先,感謝大家為 1.4 M1 里程碑版本提供的意見反應,以及提交的報告(錯誤或新功能)。特別感謝 Stéphane Nicoll,他引入了基於註釋的消息監聽器 (@RabbitListener
) 和新的 RabbitMessagingTemplate
。
@SendTo
註釋將方法的結果作為回覆消息發送(當 inbound 消息中沒有 replyTo
時)@RabbitListener(queues = "capitalize")
@SendTo("capitalize.reply")
public String capitalize(String s) {
return s.toUpperCase();
}
(基於註釋的監聽器需要 Spring Framework 4.1.x)。
引入了一個新的 RabbitMessagingTemplate
,允許使用 spring-messaging
Message<?>
抽象作為 Spring AMQP Message
的替代方案(Spring Messaging Message<?>
也受到註釋監聽器的支持)。
Logback AmqpAppender
現在可用,其配置與現有的 Log4j AmqpAppender
類似
<appender name="AMQP" class="org.springframework.amqp.rabbit.logback.AmqpAppender">
<layout>
<pattern><![CDATA[ %d %p %t [%c] - <%m>%n ]]></pattern>
</layout>
<abbreviation>36</abbreviation>
<applicationId>MyApplication</applicationId>
<routingKeyPattern>%property{applicationId}.%c.%p</routingKeyPattern>
<generateId>true</generateId>
<charset>UTF-8</charset>
<durable>false</durable>
<deliveryMode>NON_PERSISTENT</deliveryMode>
</appender>
expression
屬性的 AbstractRoutingConnectionFactory
配置 RabbitTemplate
,以根據 RabbitTemplate
操作確定目標 ConnectionFactory
<rabbit:template connection-factory="RoutingConnectionFactory"
send-connection-factory-selector-expression="messageProperties.userId"
receive-connection-factory-selector-expression="#root == 'fooQueue' ? 'foo' : null"/>
RabbitTemplate
中新增了 mandatory-expression
屬性,用於設定每個發送消息的 mandatory
標誌<rabbit:template connection-factory="connectionFactory"
mandatory-expression="messageProperties.contentType == 'application/json'"/>
(先前,mandatory
是在模板層級設定的)。
AbstractRoutingConnectionFactory
現在也支持 MessageListenerContainer
,其中用於目標 ConnectionFactory
的 key
基於配置的 queueNames
陣列