Created
June 28, 2016 12:02
-
-
Save ragingbal/a3daa05409b44d66cf07af0d242b830a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package br.com.xicojunior.redistest; | |
| import java.util.List; | |
| import redis.clients.jedis.Jedis; | |
| public class MessageConsumer | |
| { | |
| public static void main( String[] args ) | |
| { | |
| Jedis jedis = new Jedis("localhost"); | |
| List<String> messages = null; | |
| while(true){ | |
| System.out.println("Waiting for a message in the queue"); | |
| messages = jedis.blpop(0,"queue"); | |
| System.out.println("Got the message"); | |
| System.out.println("KEY:" + messages.get(0) + " VALUE:" + messages.get(1)); | |
| String payload = messages.get(1); | |
| //Do some processing with the payload | |
| System.out.println("Message received:" + payload); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment