I'm having a problem with Spring Cloud Stream. The thing is that I have a bean that will write to Kafka as soon as it's created (method annotated with @PostConstruct), so I autowire the appropriate MessageChannel and set the destination and binder properties in application.yml. It goes like this:
@Component
@RequiredArgsConstructor
public class Sender
{
private final MessageChannel output;
@PostConstruct
public void start()
{
output.send(new GenericMessage("Hello world");
}
}
And application.yml
spring:
cloud:
stream:
bindings:
output:
destination: someData
binder: kafka
I also have the following dependencies:
- spring-cloud-stream-reactive
- reactor-core
- spring-cloud-starter-stream-kafka
The project itself is starting, but I'm getting the following exception when trying to write to the output in start() method:
Caused by: org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
Is it because Kafka binder didn't manage to bind the channel yet or what? If so, what is the alternative way to this.
Thanks in advance.