Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Spring Data

You're reading from  Spring Data

Product type Book
Published in Nov 2012
Publisher Packt
ISBN-13 9781849519045
Pages 160 pages
Edition 1st Edition
Languages
Author (1):
Petri Kainulainen Petri Kainulainen
Profile icon Petri Kainulainen
Toc

The publish/subscribe messaging pattern


Redis also includes an implementation of the publish/subscribe messaging pattern. This section demonstrates how we can use Spring Data Redis for the purpose of sending and receiving messages. As an example, we will modify the CRUD application that stores the contact information as JSON to send notifications when a new contact is added, contact information is updated, and a contact is deleted.

We can implement this requirement by performing the following steps:

  1. Create message listeners that process the received messages.

  2. Configure the application context of our application.

  3. Send messages by using the RedisTemplate class.

This section also describes how we can ensure that our implementation is working correctly.

Creating message listeners

There are two ways to create message listeners by using Spring Data Redis: we can implement the MessageListener interface or we can create a POJO message listener and use the MessageListenerAdapter class to delegate messages...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime}