Tag: spring amqp

spring boot rabbitmq MappingJackson2MessageConverter自定义对象转换

我正在尝试使用spring boot创建一个简单的spring boot应用程序,它将“生成”消息发送到rabbitmq交换/队列,以及另一个“消耗”这些消息的示例spring boot应用程序。 所以我有两个应用程序(或微服务,如果你愿意)。 1)“生产者”微服务2)“消费者”微服务 “生产者”有2个域对象。 Foo和Bar应该转换为json并发送给rabbitmq。 “消费者”应该分别接收并将json消息转换为域Foo和Bar。 出于某种原因,我不能完成这个简单的任务。 关于这个的例子并不多。 对于消息转换器我想使用org.springframework.messaging.converter.MappingJackson2MessageConverter 这是我到目前为止: 生产者MICROSERVICE package demo.producer; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.Queue; import org.springframework.amqp.core.TopicExchange; import org.springframework.amqp.rabbit.core.RabbitMessagingTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.messaging.converter.MappingJackson2MessageConverter; import org.springframework.stereotype.Service; @SpringBootApplication public class ProducerApplication implements CommandLineRunner { public static void main(String[] args) { SpringApplication.run(ProducerApplication.class, args); […]

Spring RabbitMQ – 在具有@RabbitListener配置的服务上使用手动通道确认

如何在不使用自动确认的情况下手动确认消息。 有没有办法使用它与@RabbitListener和@EnableRabbit配置样式。 大多数文档告诉我们使用SimpleMessageListenerContainer和ChannelAwareMessageListener 。 但是使用它会失去注释提供的灵活性。 我已经配置了我的服务如下: @Service public class EventReceiver { @Autowired private MessageSender messageSender; @RabbitListener(queues = “${eventqueue}”) public void receiveMessage(Order order) throws Exception { // code for processing order } 我的RabbitConfiguration如下 @EnableRabbit public class RabbitApplication implements RabbitListenerConfigurer { public static void main(String[] args) { SpringApplication.run(RabbitApplication.class, args); } @Bean public MappingJackson2MessageConverter jackson2Converter() { MappingJackson2MessageConverter converter […]