Spring Cloud Stream Showcase with Apache Kafka
Add products to topic product-in-topic
, e.g.:
{"id": "001", "name": "IPad", "description": "The new 2021 IPad Pro"}
{"id": "002", "name": "Nokia X20", "description": "Middleclass Nokia Phone"}
Get products with:
http://localhost:8080/product/[id]
When scaling the application, the state is distributed among the state stores of the different instances. The interactive query service can detect the instance that is holding the requested key and can query it over RPC Mechanisms. See documentation on Confluent and Spring Cloud Stream .
To test this behaviour:
- Create the topic
product-in-topic
with multiple partitions (e.g. 3) - Create multiple instances of the application by overwriting the
server.port
property (e.g. 8080, 8081, 8082) - Produce some data to the topic
- Query a product from different instances. The log now states
Loading local product
orLoading remote product
, depending on the source
The Topology can be shown using the following endpoint:
http://localhost:8080/actuator/kafkastreamstopology/showcase