How to Use Jedis to operate Redis message queues

Source: Internet
Author: User
Tags logstash redis cluster install redis redis server

How to Use Jedis to operate Redis message queues
Resources

Jedis jar package
Commons-io jar package

Usage

The sample code is as follows. before using it, open the redis server program.

Sample Code
Package RedisExample; import redis. clients. jedis. jedis; public class TestRedis {public static void main (String [] args) {Jedis redis = new Jedis ("localhost"); // SimpleExample (redis ); // ListExample (redis, 20000); PublishExample (redis, 20000);} // Add the public static void SimpleExample (Jedis redis) {redis. set ("key1", "I am value 1"); String ss = redis. get ("key1"); System. out. println (ss);} // queue add information p Ublic static void ListExample (Jedis redis, int number) {String messageStr = ""; int count = 0; while (count ++ <number) {messageStr = "this is" + count + "message! "; Redis. rpush ("logstash-test-list", messageStr); System. out. println (messageStr) ;}// publish and subscribe to public static void PublishExample (Jedis redis, int number) {String messageStr = ""; int count = 0; while (count ++ <number) {messageStr = "this is" + count + "message! "; Redis. publish (" logstash-test-list ", messageStr); System. out. println (messageStr );}}}

Download the Jedis jar package and the Commons-io jar package:

Download the Helper home Resource Station:

------------------------------------------ Split line ------------------------------------------

Free in http://linux.bkjia.com/

The username and password are both www.bkjia.com

The specific download directory is in/July 6, 2016,/July 23, March,/How to Use Jedis to operate Redis message queues/

For the download method, see

------------------------------------------ Split line ------------------------------------------

You may also like the following articles about Redis. For details, refer:

Install and test Redis in Ubuntu 14.04

Basic configuration of Redis master-slave Replication

Redis cluster details

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

Learning notes on Redis installation and deployment

Redis. conf

Redis details: click here
Redis: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.