Spring Cloud Contract producer cannot send message

909 views Asked by At

I'm trying to incorporate Spring Cloud Contract into an existing project. I've had some success with REST but I'm struggling to set up the messaging side.

Thus far I've set up a contract on the producer, which does produce a test in target/generated-test-sources/contracts. I've also set up a base class for the test.

I can't get past this error:

2017-09-08 17:10:51.759 ERROR - --[]- [ main] o.s.c.c.v.m.stream.StreamStubMessages : Exception took place while trying to resolve the destination. Will assume the name [invites]

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.stream.config.ChannelBindingServiceProperties' available at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:353) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093) at org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages.resolvedDestination(StreamStubMessages.java:86) at org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages.receive(StreamStubMessages.java:73) at org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages.receive(StreamStubMessages.java:110) at org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages.receive(StreamStubMessages.java:36) at org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging.receive(ContractVerifierMessaging.java:40) at org.springframework.cloud.contract.verifier.tests.email.MessagingTest.validate_invitedContract(MessagingTest.java:27)

and later

2017-09-08 17:10:51.759 ERROR - --[]- [ main] o.s.c.c.v.m.stream.StreamStubMessages : Exception occurred while trying to read a message from a channel with name [invites]

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'invites' available at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1207) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)

My application.yml file under src/test/resources:

spring: cloud: stream: bindings: output: content-type: application/json destination: invites

I have the following dependencies:

`
    <!-- Spring Cloud Contract Deps -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream</artifactId>
        <version>1.2.2.RELEASE</version>
    </dependency>       

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-contract-verifier</artifactId>
        <version>1.1.3.RELEASE</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-test-support</artifactId>
        <version>1.2.2.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <!-- END SCC Deps -->`

I've combed through the docs, watched Marcin's talk and looked through the samples for Spring Cloud Contract but I'm stuck. Any help would be greatly appreciated.

1

There are 1 answers

0
Marcin Grzejszczak On BEST ANSWER

First issue:

Please use the release train. In the release train, we know that there are no invalid dependencies.

Second issue:

You don't have the @EnableBinding(Source.class) annotation. That's why Stream doesn't know how to bind to the output channel.

If you go to the Spring Cloud Contract samples you'll notice this line on the main application class (https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer/src/main/java/com/example/ProducerApplication.java#L9). After I've added this line to your code, the context started but the tests failed cause the message wasn't sent.