我正在从 Java Spring Boot 应用程序向消费者(即 Python 应用程序)发送消息。一切正常,除了当我输入命令时rabbitmqctl list_queues 它显示这video_queue 0意味着队列中没有消息。Consumer正在接收消息并进行一些漫长的过程;因此,如果我连续发送多条消息,应该有一些消息在队列中等待。我对吗?制作人:@Componentpublic class VideoProducer { private Logger logger = LoggerFactory.getLogger(VideoProducer.class); private final static String BROKER_EXCHANGE_NAME = "video_exchange"; private final static String ROUTING_KEY = "video_routing_key"; @Autowired private RabbitTemplate rabbitTemplate; @Autowired private VideoService videoService; @Autowired private Gson gson; public void produceVideo(VideoDTO video) { rabbitTemplate.convertAndSend(BROKER_EXCHANGE_NAME, ROUTING_KEY, gson.toJson(video)); } }}消费者connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))channelConsumer = connection.channel()# Video Consumer SettingschannelConsumer.exchange_declare(exchange='video_exchange', exchange_type='direct')channelConsumer.queue_declare(queue="video_queue")channelConsumer.queue_bind(queue="video_queue", exchange="video_exchange", routing_key="video_routing_key")# Consumer Listenerdef callback(ch, method, properties, body): video_dto = eval(json.loads(body)) ##Something long process here print("Done.. ") channelConsumer.basic_consume(queue='video_queue', auto_ack=True, on_message_callback=callback)print(' [*] Waiting for messages. To exit press CTRL+C')channelConsumer.start_consuming()在哪里可以看到我声明的队列上的消息?因为虽然我知道队列中有消息,但我无法使用上述命令看到它们。我也在使用 RabbitMQ 管理门户。
添加回答
举报
0/150
提交
取消