0
votes

I am learning RabbitMq using spring cloud stream java. Having doubts in the mq configuration.

As per documents - spring.cloud.stream.bindings.>channelName>.destination=dest1

I am using below configuration and it's working-

spring.cloud.stream.bindings.input.destination=dest1

But if I mention my channel name in place of input like below, it's not working - spring.cloud.stream.bindings.myChannel.destination=dest1

In my class - @INPUT('myChannel')

My doubt is why is it not working when I mention the channelName given in class and

But it is working when I give default as .input. ..?

UPDATE

MyInterface.java

String CHANNEL = myChannel;
@INPUT(CHANNEL )
SubscribableChannel subs();

MyListener.java

@StreamListener(MyInterface.CHANNEL)
public void queueMsg(String str) {
   System.out.println("Str msg = "+str);
}

application.prop

#Below property working fine
spring.cloud.stream.bindings.input.destination=dest1
spring.cloud.stream.bindings.input.binder=rabbit


#Below property NOT working 
#spring.cloud.stream.bindings.myChannel.destination=dest1
#spring.cloud.stream.bindings.myChannel.binder=rabbit
1
You need to show your listener and interface.Gary Russell

1 Answers

0
votes

The channel name is the binding name input in this case.

spring.cloud.stream.bindings.input.destination=dest1

For RabbitMQ, the destination is the exchange name that we will publish to.

Use @Input("input").

Or

spring.cloud.stream.bindings.myChannel.destination=dest1

If it's not working, you need to show your listener and interface.