I'm trying to understand concepts in Spring Cloud Stream. The 2 concepts "tap" and "named destination" are quite confusing to me.
I was trying to create a stream that has a tap called "some-source":
However, after I saved the stream, it became a "named destination":
My questions are:
A named
destination is a destination at the messaging system. For instance, an exchange
at RabbitMQ or a topic
at Apache Kafka.
Spring Cloud Stream takes care of creating these named
destinations(say RabbitMQ exchange, Apache Kafka topic) when you have your inbound/outbound bindings set to specific destination names.
In SCDF, when you create a stream, SCDF configures these destination names with a specific syntax (.<App/Label Name of the producer app>).
For instance, let's say I create a stream like this:
S1=time | t1: transform | log
When the stream S1
is deployed, you will see the destinations (if you use RabbitMQ or Apache Kafka then they will exchange or topic respectively) created with the following names:
S1.time S1.t1
Because time
and transform
being the producers.
To answer your questions:
What's the difference between a "tap" and a "named destination"?
In SCDF, a tap
is essentially a named
destination created on a producer app's outbound endpoint. Hence, when you add a tap on the stream S1's time
output then you will end up using the named
destination S1.time
.
You can create a tap
either at the time of your main stream creation (here S1) or you can create a new tap
stream later on by referring to the named destinations of the stream (here S1.time, S1.t1)
Why would a "tap" become a "named destination" after saving the stream?
Spring Cloud Stream has a consumer group model (inspired from Apache Kafka) implemented across all the binders it has support for. What this means is that, every time a new consumer is bound to a destination
at the messaging system (say an exchange
at RabbitMQ or a topic
at Apache Kafka), a new consumer group is created for that destination. A tap
is nothing but creating a new stream which forms a new consumer group on a specific named
destination.
There is one more case to add.
Let's say you want to create a stream that is not from an outbound endpoint of an existing stream but want to point to a specific named
destination which has data from some other system. In those cases, you would use the named
destination to create a stream. Because of the Spring Cloud Stream's consumer group model, you will create a new consumer group on this named
destination as well.
For instance, let's say I have a RabbitMQ exchange or a Kafka topic named user_data
which already receive data from other source that is not part of SCDF stream, then you will create a new stream like this:
:user_data > transform | jdbc
The prefix :
is used to refer a named destination in SCDF.