vincent
vincent

Reputation: 1234

Spring cloud stream with reactive streams


my goal is to make an application using Spring cloud stream and Kafka, and discover the "reactive" world. I've something that works. Here is a part of my consumer. In my pom, i've declared :

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-kafka</artifactId>
        </dependency>

That's 1.0.0.RELEASE that i use.
I've declared my channels

public interface MyChannels {

    public static final String TOPIC_NAME = "myTopicName";

    @Input(TOPIC_NAME)
    MessageChannel receive();
}

and then my service

@MessageEndpoint
@EnableBinding(MyChannels.class)
public class MyConsumer {

    @Autowired
    private MyChannels channels;

    @ServiceActivator(inputChannel=MyChannels.TOPIC_NAME)
    public void receive(MyObject object) {
        //apply my business logic
        //like save my object in a database
    }
}

I receive my message well. I've seen in my dependencies that spring-integration-kafka depends on reactor-core. Is it sufficient to make my app "reactive" ? What should i do to apply the reactive programming style ?

Do i have to use the @EnableRxJavaProcessor, if yes, i don't understand how.

If i'm not clear, don't hesitate to write it in comment. thanks

Upvotes: 4

Views: 3609

Answers (1)

Marius Bogoevici
Marius Bogoevici

Reputation: 2400

The use of Reactor is internal to the project and does not make your application reactive (not just yet :) ).

The use of RxJava support is covered by the reference documentation here: http://docs.spring.io/spring-cloud-stream/docs/current/reference/htmlsingle/#_rxjava_support

We do intend to provide broader support in Spring Cloud Stream 1.1 here: https://github.com/spring-cloud/spring-cloud-stream/issues/458

Cheers, Marius

Upvotes: 6

Related Questions