我正在從 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
提交
取消