读书人

rabbitmq学习八:spring-amqp的重要类的

发布时间: 2012-08-30 09:55:54 作者: rapoo

rabbitmq学习8:spring-amqp的重要类的认识

?? 对于大多数应用来说都做了与spring整合,对于rabbitmq来说。也有与spring的整合。可能通过spring的官网找到spring-amqp项目下载。spring-amqp项目包括三个子项目:spring-amqp、spring-erlang、spring-rabbit.

?? 下面来认识一下spring-amqp中的几个重要类;以spring-amqp-1.0.0.M3版本为例

??? 1、Message: Spring AMQP定义的Message类是AMQP域模型中代表之一。Message类封装了body(消息BODY)和properties(消息属性) 。使得这个API看起来很简单。Message类定义如下:

public interface AmqpTemplate {// send methods for messagesvoid send(Message message) throws AmqpException;void send(String routingKey, Message message) throws AmqpException;void send(String exchange, String routingKey, Message message) throws AmqpException;// send methods with conversionvoid convertAndSend(Object message) throws AmqpException;void convertAndSend(String routingKey, Object message) throws AmqpException;void convertAndSend(String exchange, String routingKey, Object message) throws AmqpException;void convertAndSend(Object message, MessagePostProcessor messagePostProcessor) throws AmqpException;void convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException;void convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException;// receive methods for messagesMessage receive() throws AmqpException;Message receive(String queueName) throws AmqpException;// receive methods with conversionObject receiveAndConvert() throws AmqpException;Object receiveAndConvert(String queueName) throws AmqpException;// send and receive methods for messagesMessage sendAndReceive(Message message) throws AmqpException;Message sendAndReceive(String routingKey, Message message) throws AmqpException;Message sendAndReceive(String exchange, String routingKey, Message message) throws AmqpException;// send and receive methods with conversionObject convertSendAndReceive(Object message) throws AmqpException;Object convertSendAndReceive(String routingKey, Object message) throws AmqpException;Object convertSendAndReceive(String exchange, String routingKey, Object message) throws AmqpException;}

?6、AmqpAdmin和RabbitAdmin

?? 用户配置Queue、Exchange、Binding的代理类。代理类会自动声明或创建这些配置信息。

下面这个类用于异步接收消息的处理类

?? 7、MessageConverter 消息转换器类

?8、SimpleMessageListenerContainer 监听消息容器类

读书人网 >软件架构设计

热点推荐