Java 如何为python发送方创建spring引导rabbitmq使用者?

Java 如何为python发送方创建spring引导rabbitmq使用者?,java,spring-boot,rabbitmq,spring-rabbit,Java,Spring Boot,Rabbitmq,Spring Rabbit,我想开发一个应用程序,其中python代码使用rabbitmq发送消息,使用者是Spring boot rabbitmq代码 sender.py #!/usr/bin/env python import pika import sys connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost')) channel = connection.channel() channel.exchange_

我想开发一个应用程序,其中python代码使用rabbitmq发送消息,使用者是Spring boot rabbitmq代码

sender.py

#!/usr/bin/env python
import pika
import sys

connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.exchange_declare(exchange='topic_logs',
                     exchange_type='topic')

routing_key = sys.argv[1] if len(sys.argv) > 2 else 'anonymous.info'
message = ' '.join(sys.argv[2:]) or 'Hello World!'
channel.basic_publish(exchange='topic_logs',
                  routing_key=routing_key,
                  body=message)
print(" [x] Sent %r:%r" % (routing_key, message))
connection.close()
如何使用spring引导配置rabbitmq接收器?接收器端需要什么样的必要配置?请帮忙

@SpringBootApplication
public class So49512910Application {

    public static void main(String[] args) {
        SpringApplication.run(So49512910Application.class, args);
    }

    @Bean
    public Queue queue() {
        return new Queue("someQueue");
    }

    @Bean
    public TopicExchange exchange() {
        return new TopicExchange("topic_logs");
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue()).to(exchange()).with("whatever.topic.pattern.you.want.to.match");
    }

    @RabbitListener(queues = "someQueue")
    public void listener(String in) {
        System.out.println(in);
    }

}
或者,如果交换已经存在

@SpringBootApplication
public class So49512910Application {

    public static void main(String[] args) {
        SpringApplication.run(So49512910Application.class, args);
    }

    @Bean
    public Queue queue() {
        return new Queue("someQueue");
    }

    @Bean
    public Binding binding() {
        return new Binding("someQueue", DestinationType.QUEUE, "topic_logs", "rk.pattern", null);
    }

    @RabbitListener(queues = "someQueue")
    public void listener(String in) {
        System.out.println(in);
    }

}

真 的。非常感谢你,先生。这就是我要找的。你的答案很清楚……帮了我大忙,谢谢:)哇……非常感谢你,先生。这是我一直在寻找的东西。谢谢。你的答案非常清楚,非常准确:)