spring-cloud / spring-cloud/spring-cloud-stream

How to bind to two groups with the same destination?

Open
#2,334 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
646
Avg merge
2d 3h
Merged PRs (30d)
8

Description

@sabbyanandan commented on Tue May 04 2021

@Synchronized1 commented on Fri Dec 11 2020

This working mode is similar to rabbitmq:https://www.rabbitmq.com/tutorials/tutorial-five-python.html

image

 spring:
  rabbitmq:
    addresses: 192.168.1.102
    username: admin
    password: 123456
    virtual-host: myVH
  cloud:
    stream:
      binders:  
        myRabbitMQ:  
          type: rabbit  
      bindings:
        orderMsgOutput:
          destination: order.exchange 
          binder: myRabbitMQ
          group: order.release.queue  
        orderMsgInput:
          destination: order.exchange 
          binder: myRabbitMQ
          group: order.release.queue  

        stockMsgOutput:
          destination: stock.exchange  
          binder: myRabbitMQ
          group: stock.release.queue  
        stockMsgInput:
          destination: stock.exchange  
          binder: myRabbitMQ
          group: stock.release.queue  
 
        orderReleaseStockOutput:
          destination: order.exchange 
          binder: myRabbitMQ
          group: stock.release.queue 

        orderReleaseStockInput:
          destination: order.exchange
          binder: myRabbitMQ
          group: stock.release.queue

      rabbit:
        bindings:
          orderMsgOutput:
            producer:
              delayedExchange: true  
              routingKeyExpression: '''order.release'''  
          orderMsgInput:
            consumer:
              delayedExchange: true  
              bindingRoutingKey: order.release.#  
              acknowledgeMode: manual  
              queueNameGroupOnly: true  
          stockMsgOutput:
            producer:
              delayedExchange: true  
              routingKeyExpression: '''stock.release'''  

          stockMsgInput:
            consumer:
              delayedExchange: true  
              bindingRoutingKey: stock.release.#  
              acknowledgeMode: manual  
              queueNameGroupOnly: true

          orderReleaseStockOutput:
            producer:
              delayedExchange: true 
              routingKeyExpression: '''order.stock.release''' 

          orderReleaseStockInput:
            consumer:
              delayedExchange: true  
              bindingRoutingKey: order.stock.release.#  
              acknowledgeMode: manual  
              queueNameGroupOnly: true

I want order.exchange to be bound with stock.release.queue and order.release.queue at the same time

image

  2020-12-11 21:01:24.796 ERROR 18836 --- [ask-scheduler-2] o.s.cloud.stream.binding.BindingService  : Failed to create consumer binding; retrying in 30 seconds

org.springframework.cloud.stream.binder.BinderException: Exception thrown while starting consumer: 
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:461) ~[spring-cloud-stream-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:90) ~[spring-cloud-stream-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractBinder.bindConsumer(AbstractBinder.java:143) ~[spring-cloud-stream-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	at org.springframework.cloud.stream.binding.BindingService.lambda$rescheduleConsumerBinding$1(BindingService.java:201) ~[spring-cloud-stream-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_172]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_172]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_172]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[na:1.8.0_172]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_172]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_172]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_172]
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'stock.release.queue.errors.recoverer' defined in null: Cannot register bean definition [Root bean: class [org.springframework.integration.handler.advice.ErrorMessageSendingRecoverer]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'stock.release.queue.errors.recoverer': There is already [Root bean: class [org.springframework.integration.handler.advice.ErrorMessageSendingRecoverer]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.registerBeanDefinition(DefaultListableBeanFactory.java:945) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.GenericApplicationContext.registerBeanDefinition(GenericApplicationContext.java:323) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.GenericApplicationContext.registerBean(GenericApplicationContext.java:471) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.registerErrorInfrastructure(AbstractMessageChannelBinder.java:681) ~[spring-cloud-stream-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.registerErrorInfrastructure(AbstractMessageChannelBinder.java:633) ~[spring-cloud-stream-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	at org.springframework.cloud.stream.binder.rabbit.RabbitMessageChannelBinder.createConsumerEndpoint(RabbitMessageChannelBinder.java:511) ~[spring-cloud-stream-binder-rabbit-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	at org.springframework.cloud.stream.binder.rabbit.RabbitMessageChannelBinder.createConsumerEndpoint(RabbitMessageChannelBinder.java:129) ~[spring-cloud-stream-binder-rabbit-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	at org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:407) ~[spring-cloud-stream-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	... 11 common frames omitted

The monitoring station of rabbimq looks normal, but the program throws an exception

image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining AbstractMessageChannelBinder.registerErrorInfrastructure and RabbitMessageChannelBinder.createConsumerEndpoint, the entry points named in the stack trace. Reproduce the configuration with both groups using the same destination, then determine whether consumer binding can complete without the duplicate stock.release.queue.errors.recoverer definition; add or update coverage for the supported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, rabbitmq, spring
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.