Integrating Redis with a Helidon MicroProfile Application for a Publish-Subscribe Usecase
Redis is an open source, in-memory data structure store, used as a database, cache and message broker. In this short post I am sharing a simple application that show cases classic integration of Redis message broker(pub/sub) APIs with a Helidon MicroProfile application for message publish-subscribe use case. You can checkout the source form here: https://github.com/jobinesh/cloud-native-applications/blob/master/helidon-example-mp-redis/README.md
What is the usecase exercised in this example ?
It is simple :) We use the a simple greeting REST API to exercise the Redis Publish Subscribe feature. When a client updates the greeting message, the Greeting resource implementation will publish the new greeting message to Redis channel topic for use by interested parties(consumers)
Who does what?
Here is quick summary of the classes that you find in the source:
All instructions are available here: https://github.com/jobinesh/cloud-native-applications/blob/master/helidon-example-mp-redis/README.md. Have fun !
What is the usecase exercised in this example ?
It is simple :) We use the a simple greeting REST API to exercise the Redis Publish Subscribe feature. When a client updates the greeting message, the Greeting resource implementation will publish the new greeting message to Redis channel topic for use by interested parties(consumers)
Who does what?
Here is quick summary of the classes that you find in the source:
- Lettuce: This example use Lettuce client library to connect to Redis server. If you are new to Lettuce, take a look at the following resources to get a feel of the offerings:
- RedisMessageConsumer: This class contains the logic for listening to the Redis channel. This class uses a custom annotation '@Startup' so that it gets instantiated on application start up. The annotation '@Startup' is provided by io.helidon.examples.mp.spi.StartupInitializerExtension class in this project. To learn more about this extension, read section '16.1. Creating an Extension' in https://docs.jboss.org/weld/reference/latest/en-US/html/extend.html
- RedisMessageProducer: This class contains the logic for publishing messages to the Redis channel. It is used by GreetResource class.
- GreetResource: This is the REST resource implementation used in this example. When updateGreeting method is called via REST PUT operation, the new greeting sent by client is sent to Redis channel for consumption by the consumers. See the method updateGreeting() in GreetResource class to learn the usage of RedisMessageProducer class in order to publish message to channel.
- microprofile-config.properties: This config file holds the Redis configuration used in this example
All instructions are available here: https://github.com/jobinesh/cloud-native-applications/blob/master/helidon-example-mp-redis/README.md. Have fun !
I am very thankful to you for sharing this excellent knowledge. This information is helpful for everyone. So please always share this kind of information. Thanks. Buy Birthday card for boy online USA
ReplyDeleteExcellent information, I am heartily very thankful to you for providing this kind of knowledge. This information will always help to everyone for gaining knowledge. Always keep sharing. Thanks.Sell Damaged MacBook Pro A1398
ReplyDelete