Skip to content

Instantly share code, notes, and snippets.

@ragingbal
Created June 28, 2016 12:02
Show Gist options
  • Select an option

  • Save ragingbal/a3daa05409b44d66cf07af0d242b830a to your computer and use it in GitHub Desktop.

Select an option

Save ragingbal/a3daa05409b44d66cf07af0d242b830a to your computer and use it in GitHub Desktop.
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