Spring Cloud Stream connection with RabbitMQ

前端 未结 1 679
别那么骄傲
别那么骄傲 2021-01-27 09:39

have a simple Spring-Cloud-Stream project that I try to connect with RabbitMQ, It says its connected but It\'s not working. Did I do something wrong in the code?

1条回答
  •  星月不相逢
    2021-01-27 10:21

    To setup spring cloud stream with rabbitmq binder implementation you need to configure this in your pom.xml 1.

     
                org.springframework.cloud
                spring-cloud-stream
     
     
                org.springframework.cloud
                spring-cloud-stream-binder-rabbit
     
     
                org.springframework.boot
                spring-boot-starter-amqp
     
    

    then you define this in your application.properties/yaml

    2.

    spring:
        cloud:
            stream:
                bindings:
                    greetingChannel
                        destination: test.greeting
                        group: queue
                rabbit:
                    bindings:
                        greetingChannel:
                            producer:
                                transacted: true //optional
    
    
    1. EnableBinding(HelloBinding.class)
    2. Inject binding and use it
    helloBinding.greeting().send(MessageBuilder
                    .withPayload(...)
                    .build());
    
    1. Setup of rabbitMQ properties

    0 讨论(0)
提交回复
热议问题