#手动应答
#spring.rabbitmq.listener.simple.acknowledge-mode=manual
#spring.rabbitmq.listener.simple.acknowledge-mode=none
#不发生异常才应答
#spring.rabbitmq.listener.simple.acknowledge-mode=auto
@Component
@RabbitListener(queues="first",containerFactory="rabbitListenerContainerFactory" )//使用特定的监听工厂类
public class FirstConsumer {
@RabbitHandler
public void process(@Payload Tests jsonpObject, Message message, Channel channel) throws IOException {
// factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);开启了手动配置后
//处理自己得业务
System.out.println(jsonpObject);
// 处理完自己的业务后 手动应答
// 这里需要手动设置消息确认
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
}
}