neng zhang
neng zhang

Reputation: 11

How to config multiple nameservers using spring-cloud-stream-rocketmq

Trying to develop a microservices project using the spring-cloud-stream-rocketmq. I have the default rocketmq server and my configuration is

  spring:
  cloud:
    stream:
      default-binder: rocketmq
      rocketmq:
        binder:
          name-server: nameserver1
        bindings:
          output1:
            producer:
              transactional: false
      bindings:
        output1:
          destination: topic1
        output2:  
          destination: topic2

But not i want to access another rocketmq server .How should i change the configuration to use both rocketmq server.Please help me

Upvotes: 1

Views: 292

Answers (2)

jamesZuo
jamesZuo

Reputation: 1

server:
  port: 10086
spring:
  cloud:
    stream:
      default:
        producer:
          use-native-encoding: true
        consumer:
          use-native-encoding: true
      binders:
        binder1:
          type: rocketmq
          environment:
            spring.cloud.stream.rocketmq:
              binder:
                name-server: localhost:9876
                #          accessKey: skXXXX
                #          secretKey: skXXXX
                enable-msg-trace: false
                group: demo-group-1
              bindings:
                topic-demo-out-0:
                  producer:
                    group: delayed-group
                    #必须要设置sync为true,延迟消息才会生效
                    sync: true
                handleDemoMsg-in-0:
                  consumer:
                    enable: true
                    broadcasting: false
                    orderly: false
                handlePaymentCompletedMsg-in-0:
                  consumer:
                    enable: true
                    broadcasting: false
                    orderly: false
        binder2:
          type: rocketmq
          environment:
            spring.cloud.stream.rocketmq:
              binder:
                name-server: localhost:9876
                #          accessKey: akXXXX
                #          secretKey: skXXXX
                enable-msg-trace: false
                group: demo-group-2
              bindings:
                topic-demo2-out-0:
                  producer:
                    group: delayed-group
                    #必须要设置sync为true,延迟消息才会生效
                    sync: true
      default-binder: binder1
      bindings:
        topic-demo-out-0:
          destination: topic-demo
        topic-demo2-out-0:
          destination: topic-demo2
          binder: binder2
        handleDemoMsg-in-0:
          content-type: application/json
          destination: topic-demo
          group: demo-group-1
      function:
        definition: handleDemoMsg,handlePaymentCompletedMsg

Upvotes: -1

wudi1940
wudi1940

Reputation: 1

multiple nameserver means you are using a cluster!

The configs of broker should be seted properly too

use clustername or try "nameserverIP1;nameserverIP2"

Upvotes: 0

Related Questions