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...