Peeking at Spring Cloud Stream (with RabbitMQ)

Linking lots of small services together via messaging is a very common pattern. It increases in popularity with the rise of microservices. Coding the same pattern over and over using RabbitTemplate or some other transport template (KafkaTemplate and others) is another level of complexity we shouldn't be saddled with.

Spring Cloud Stream (http://cloud.spring.io/spring-cloud-stream/) to the rescue!

Spring Cloud Stream takes the concept of inputs, outputs, and transformers from Spring Integration and makes it super easy to chain them together.

To alter our social media platform to do this, we can remove spring-boot-starter-amqp from our build file and add this instead:

    compile(
'org.springframework.cloud:spring-cloud-starter-stream-rabbit') compile(
'org.springframework.cloud:spring-cloud-stream-reactive')

This preceding dependency brings in the following:

  • spring-cloud-stream-binder-rabbit-core
  • spring-cloud-stream-codec
  • spring-cloud-stream
  • spring-cloud-stream-reactive
  • spring-boot-starter-amqp
  • spring-integration-amqp
Spring Cloud Stream has many starters. In essence, we must pick the underlying transport technology, but we don't have to interact with the transport technology directly.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.119.170