Click here to Skip to main content
11,812,712 members (72,768 online)
Click here to Skip to main content

Redis Tutorial Part II: Using Redis as a Pub/Sub Medium

, 2 May 2011 CPOL 15.8K 10.3K 3
Rate this:
Please Sign up or sign in to vote.
Create a simple redis pub/sub client pair in VB.NET


If you have gone through Part I of this series, you will now have a bit of an idea of what redis is and its simple but awesome power. This part explains how redis can act as a publish - subscribe medium. In simpler terms- Notifications: the simplest of things that makes coding so much easier! This series will conclude with Part III: Creating a chat system with Redis in VB.NET.


As with its predecessor, this tutorial is going to be simple and direct. I can show you what powers you, not how to use them Big Grin | :-D . One of the most powerful features of redis is its PubSub mode. In other words, when something happens, anything that wants to know it will be informed. This tutorial will show you the fundamental way to use this. My next tutorial will show how to develop a complete chat application (twitter/Facebook) in VB.NET. I know that mostly applications like that are developed in the web platform, but for the purpose of these tutorials, I am going to use it anyway.

Using the Code

The prerequisites are the same as from part I. You can use the same project or build a new one.

Here, we'll have a single application that can be run in 2 modes:

  1. As a Subscriber
  2. As a Publisher

I've built the project in such a way that this is toggled by a menu at startup. You may use it as different applications too! Run the EXE more than once to use it...

Imports ServiceStack.Redis

Public Class SubscriptionMessageEventArgs
    Inherits EventArgs

    Public Property Key As String
    Public Property value As String

    ''' <span class="code-SummaryComment"><summary>

To subscribe to an array of channels, call the Subscribe function. To publish to a channel, call the Publish function. As you may see, a client that subscribes cannot do anything else. We deal with this situation in the next tutorial, unless of course you figure out the simple solution for it on your own!

Well, that's it for the second part of the tutorial. Do ask and comment if you have any queries.


  • 1st May, 2011: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Hariharan Arunachalam
India India
Hariharan leapt into the field of programming after being introduced to C in his second year at college. A fan of basketball and chess, the logical thought process behind programming and the concepts of linking real principles onto a concrete platform pushed him deep into this field. On finishing his bachelor's majoring in Electrical and Electronics engineering with Soft Computing, Numerical Analysis and Biomedical Engineering as minor, he did a six month stint at India's second largest IT company- Infosys Technologies. He left Infosys armed with strong concepts of SDL Cycles and process development, gained domain knowledge in Java and had explored Visual basic, C++, C# and kept his mind open for more. Currently working in a startup as the product designer, his arsenal of technologies has doubled to accommodate the challenges his job demands.
Off work, he enjoys learning new languages (non-programming) and is currently teaching himself German and Spanish. He also enjoys travelling around and exploring new ideas, places and relationships.

Currently attempting to extend his education to post graduation.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151002.1 | Last Updated 2 May 2011
Article Copyright 2011 by Hariharan Arunachalam
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid