question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

random 'Dispatcher has no subscribers for channel' behaviour

See original GitHub issue

Hi – I’ve got a spring boot application where a front end listens for RESTful requests and sends messages to another spring boot application in the same JVM to do work. the front end, before sending, creates a new topic on the fly based on a sequence number and includes that sequence number in the request to the back so that it knows to which topic to send the reply. it blocks for 20 seconds in polling for the response. it then deletes the topic when it’s done receiving the response (or after timeout). the backend is an @StreamListener

my problem is that the application behaves randomly between bootruns -

  1. round trip requests/responses work 100%
  2. round trip requests/responses work after a first failure where the backend replies on the unique response topic, but the front end, on a poll of 20 seconds, times out with no response
  3. 100% failure where the logs say ‘Dispatcher has no subscribers for channel’ and the backend listener method is never called
  4. same as 2 or 3, but after starting up, the listener picks up all of the “lost” messages from the previous round of tests

I’m somewhat new to Spring, but I’ve scoured the net for samples and pieced this together. why would it work randomly like that?

The consumer… note that logging shows that the @PostConstruct method is always invoked without fail. I tried the class as a Service as well.

@Component
@Slf4j
public class MessageConsumer {

  @Autowired
  KafkaTemplate<String, String> kafkaTemplate;

  @Autowired
  JsonMapper jsonMapper;

  @PostConstruct
  public void init() {
    System.out.println("MessageConsumer.init()");
    log.debug("MessageConsumer.init()");
  }

  @StreamListener(PartnerIntegrationRequest.PARTNER_INTEGRATION_REQUEST_LISTENER)
  public void receive(String payload) {
    log.info("got message: " + payload);

    Map<String, Object> payloadData = jsonMapper.parse(payload);
    String transactionId = (String) payloadData.get(Constants.TRANSACTION_ID.getValue());
    payloadData.put(Constants.STATUS.getValue(), "success");

    String topicName = "response-" + transactionId;
    log.debug("replying to topic ["+topicName+"]");
    kafkaTemplate.send(topicName, transactionId, jsonMapper.stringify(payloadData));
  }

}

The interface …

public interface PartnerIntegrationRequest {

  public static final String PARTNER_INTEGRATION_REQUEST_PRODUCER = "partnerIntegrationRequestProducer";
  public static final String PARTNER_INTEGRATION_REQUEST_LISTENER = "partnerIntegrationRequestListener";

  @Output
  MessageChannel partnerIntegrationRequestProducer();

  @Input
  SubscribableChannel partnerIntegrationRequestListener();
}

Front end sending code…

private boolean sendMessageToPartnerIntegration(String stringify) {
    log.debug("sending message: {}", stringify);
    boolean result = partnerIntegrationRequest.partnerIntegrationRequestProducer().send(new GenericMessage<String>(stringify),
        10000);
    log.debug("send result {}", ""+result);
    return result;
  }

and front-end properties:

spring.cloud.stream.bindings.partnerIntegrationRequestProducer.destination=partnerIntegrationRequestListener
spring.cloud.stream.bindings.partnerIntegrationRequestProducer.content-type=application/json
spring.cloud.stream.bindings.partnerIntegrationRequestListener.destination=partnerIntegrationRequestListener
spring.cloud.stream.bindings.partnerIntegrationRequestListener.content-type=application/json
spring.cloud.stream.bindings.partnerIntegrationRequestListener.group=integrationsGroup
spring.cloud.stream.bindings.partnerIntegrationResponse.destination=endpointsResponseTopic
spring.cloud.stream.bindings.partnerIntegrationResponse.content-type=application/json
#spring.cloud.stream.bindings.partnerIntegrationResponse.group=endpointsGroup
spring.cloud.stream.kafka.bindings.input.consumer.resetOffsets=true

for the backend properties, they are identical except that I have resetOffsets commented out. Hacking away with various little tweaks to see it work or not.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mbogoevicicommented, Apr 21, 2017

@pts-danielmanley Thanks for reaching out. Dispatcher has no subscribers for channel typically means that some beans are initialized in the wrong order. It’s hard to tell what is going on there just from publishing/subscribing code. Would it be possible to publish a complete example that reproduces what you’re experiencing?

0reactions
jkinzercommented, Aug 18, 2017

@pts-danielmanley we just ran into this issue in our application that is using consumers and producers in the same application over the same channels. It seems like there is an opportunity for improvement here: the framework could throw an error if it attempts to bind a consumer and producer on the same channel name?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TCP Spring Integration - Dispatcher has no subscribers for ...
Getting "Dispatcher has no subscribers for channel " for response channel. Everything is working fine except the response not getting transported on ...
Read more >
Spring Integration 5: Subscribable Message Channels
MessageDeliveryException : Dispatcher has no subscribers for channel 'MessageChannelWithNoSubscribers'.; nested exception is ...
Read more >
spring-cloud/spring-cloud-stream - Gitter
Unlike with KafkaListener , there is no support in stream for "queueing" seek ... MessageDeliveryException: Dispatcher has no subscribers for channel ...
Read more >
Configuration - Documentation - Akka
Akka is a toolkit for building highly concurrent, distributed, and resilient message-driven applications for Java and Scala.
Read more >
911 dispatcher cleared in "weed" conversation
An Augusta 911 Center dispatcher has been cleared of any wrong-doing after she was heard stating she gets "to smoke weed" over a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found