我需要将消息发送到名为“myQueue”的队列到 MQ 服务器。我应该在 Spring 声明所有必需的bean,例如队列等吗?在我看来,这没什么用,因为我只需要发送到服务器,并在可能的情况下接收,我不会监听队列,是否可以将其扔在那里然后忘记,而无需任何显式配置?
最佳答案
I need to send a message to a queue with name "myQueue" to the MQ server.
Should I declare all required beans in spring, like Queue and etc for it.
没有。如果不声明连接工厂、交换和队列等 bean,您就无法将消息发布到队列。
It seems to me useless because I only need to send to server, and receive if possible,
I`m not going to listen the queue, is it possible just to throw it there and forget, without any explicit configuration?
Spring 并不是 super 自然,尽管无论您是否消费消息,如果您想将消息推送到队列,Spring 都应该知道连接和队列详细信息。
您可以引用my blog post有关 spring-rabbit 编程的更多详细信息。
关于java - springrabbit是否需要声明队列来发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29842165/