0
votes

I'm trying to implement a basic Processor from spring-cloud-stream. I've done this before on other projects, so I thought I was familiar with it. But this time Spring is having a problem creating via @Autowire my Processor reference inside a @Service component.

I thought the important piece was the @EnableBinding(my.class) on the Application, but I have that.

The error is

No qualifying bean of type 'com.mycompany.config.BizSyncProcessor' available

I also tried adding an @Component to the BizSyncProcessor, but that made no difference.

Here are the pieces:

public interface BizSyncProcessor {

    String BUSINESS_IDS_INPUT = "updatedBusinessIdsIn";
    String BUSINESS_IDS_OUTPUT = "updatedBusinessIdsOut";

    @Output(BizSyncProcessor.BUSINESS_IDS_OUTPUT)
    MessageChannel writeUpdatedBusinessIds();

    @Input(BizSyncProcessor.BUSINESS_IDS_INPUT)
    MessageChannel readUpdatedBusinessIds();

}

@Service
public class BusinessService {

    @Autowired
    private BizSyncProcessor bizSyncProcessor;

    // methods which reference bizSyncProcessor's input and outputs
}

@EnableBinding(BizSyncProcessor.class)
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
1
Sounds like you don't have any binder implementation in your classpath! - Artem Bilan
Looks like that was it! Thanks! At least, getting past that start up error. I added spring-cloud-stream-binder-rabbit dependency and that cleared up this error. Still not sure I'm actually writing to it, but that's a separate issue. Write this up as an answer and I'll mark it as the answer. Also, is this mentioned in the docs anywhere that you need a binder implementation on the classpath? - user26270

1 Answers

1
votes

The @EnableBinding(BizSyncProcessor.class) does not have any sense without some Binder implementation presented in the application classpath. Exactly that tool does the actual binding and provides particular beans for us for dependency injection.

Yeah... Looks like there is no clear sentence in the Docs that Binder implementation must be present to trigger binding interface proxying and registering it as a bean: http://cloud.spring.io/spring-cloud-static/spring-cloud-stream/2.1.0.RC3/single/spring-cloud-stream.html#_destination_binders

Feel free to raise a GitHub issue to ask ask such a doc improvement!