Rabbitmq 如何发送&;使用Spring AMQP中的对象?
我想使用Spring AMQP发送和使用如下自定义对象 生产者代码 记录记录=新记录(“消息1”,新日期())Rabbitmq 如何发送&;使用Spring AMQP中的对象?,rabbitmq,config,amqp,spring-amqp,Rabbitmq,Config,Amqp,Spring Amqp,我想使用Spring AMQP发送和使用如下自定义对象 生产者代码 记录记录=新记录(“消息1”,新日期()) rabbitTemplate.convertAndSend(记录) 任何人都可以提供spring amqp@configuration设置来发送和使用上述消息。谢谢 你应该看看;其中一些使用@Configuration 但是,本质上,你需要 @Bean public SimpleMessageListenerContainer container() { SimpleMessa
rabbitTemplate.convertAndSend(记录)
任何人都可以提供spring amqp@configuration设置来发送和使用上述消息。谢谢 你应该看看;其中一些使用
@Configuration
但是,本质上,你需要
@Bean
public SimpleMessageListenerContainer container() {
SimpleMessageListenerContainer container =
new SimpleMessageListenerContainer(connectionFactory());
MessageListenerAdapter adapter = new MessageListenerAdapter(myListener());
container.setMessageListener(adapter);
container.setQueues(foo());
return container;
}
@Bean
public Object myListener() {
return new Foo();
}
而听众可以是一个POJO
public class Foo {
public void handleMessage(Record foo) {
System.out.println(foo);
}
}
编辑:
对于XML版本。感谢Russell,他能够使用这些对象。\n我希望看到一个使用XML配置的示例。我可以发送/接收字符串,但不能接收对象。我可以发送对象,但应用程序从未接收到它们。Rabbit MQs CPU在发送1条消息后跳到100%,并一直保持100%,直到我丢弃队列,所以它有点卡住。请参阅