Coder Social home page Coder Social logo

disque4j's Introduction

disque4j

A simple redis message queue for Java.

一个易于使用的基于redis的消息队列, 不支持集群消费.

快速开始

  1. 添加依赖

    <dependency>
        <groupId>com.github.lkqm</groupId>
        <artifactId>disque4j</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>
  2. 生产者

    MessageProducers.publish("order", "add", "Add one order.");
    
  3. 消费者

    @RedisListener(topic="order", tags="add")
    public class OrderConsumer implements MessageListener {
        
       @Override
        public void onMessage(Message message) {
            System.out.println("receive message: " + message);
        }
    }
  4. 配置

    disque.enabled=true                               # 开启, 默认: false
    disque.key-prefix=disque                          # 设置key前置, 默认: disque
    disque.pool.core-size=1                           # 核心线程数量, 默认: 1
    disque.pool.max-size=8                            # 最大线程数量, 默认: 8
    disque.topics.YOUR_TOPIC.pool.core-size=1         # 配置指定队列的线程池
    disque.topics.YOUR_TOPIC.pool.max-size=8          # 配置指定队列的线程池
    disque.topics.YOUR_TOPIC.pool.keep-alive=         # 配置指定队列的线程池
    disque.topics.YOUR_TOPIC.pool.queue-capacity=     # 配置指定队列的线程池

警告

请确保redis连接超时 > 5秒(bpop阻塞时间), 否则会出现消息丢失, 默认redis连接不会超时。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.