Skip to content

Pub/Sub Messaging

Spring Data provides dedicated messaging integration for Valkey, similar in functionality and naming to the JMS integration in Spring Framework.

Valkey messaging can be roughly divided into two areas of functionality:

  • Publication or production of messages
  • Subscription or consumption of messages

This is an example of the pattern often called Publish/Subscribe (Pub/Sub for short). The ValkeyTemplate class is used for message production. For asynchronous reception similar to Java EE’s message-driven bean style, Spring Data provides a dedicated message listener container that is used to create Message-Driven POJOs (MDPs) and, for synchronous reception, the ValkeyConnection contract.

The io.valkey.springframework.data.valkey.connection and io.valkey.springframework.data.valkey.listener packages provide the core functionality for Valkey messaging.