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

You're reading from   Spring Data Want to make it easier to implement data access with your Spring-powered applications? Then this is the book you need. A complete tutorial to Spring Data, it makes learning easier with lots of code examples and clear instructions.

Arrow left icon
Product type Paperback
Published in Nov 2012
Publisher Packt
ISBN-13 9781849519045
Length 160 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Petri Kainulainen Petri Kainulainen
Author Profile Icon Petri Kainulainen
Petri Kainulainen
Arrow right icon
View More author details
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 $19.99/month. Cancel anytime
Banner background image