FolkMQ

内存型消息中间件(单机版,约 180K TPS)。"单线程"、"多路复用"、"快照持久化" 和 "Broker 模式集群"!

支持定时消息,过期消息,顺序消息,事务消息,请求消息。支持确认、重试、延时。支持 Qos0、Qos1。
//server
docker run -p 18602:18602 -p 8602:8602 noearorg/folkmq-server:1.2.4

publish / subscribe
send / listen
//client
public class ClientDemo {
    public static void main(String[] args) throws Exception {
        //客户端
        MqClient client = FolkMQ.createClient("folkmq://127.0.0.1:18602")
                                .nameAs("demoapp")
                                .connect();

        //订阅
        client.subscribe("demo", message -> {
            System.out.println(message);
        });
        
        //发布
        client.publish("demo", new MqMessage("helloworld!"));
    }
}
//client
public class ClientDemo {
    public static void main(String[] args) throws Exception {
        //客户端1
        MqClient client1 = FolkMQ.createClient("folkmq://127.0.0.1:18602")
                                .nameAs("demoapp1")
                                .connect();

        //客户端1监听
        client1.listen(new MqRouter(m -> m.getTag()).doOn("hello", req -> {
            System.out.println(request);
            req.response(new StringEntity("me to!"));
        }));
        
        
        //客户端2
        MqClient client2 = FolkMQ.createClient("folkmq://127.0.0.1:18602")
                                .nameAs("demoapp2")
                                .connect();
        
        //客户端2发送
        Reply resp = client2.send(new MqMessage("helloworld!").tag("hello"), "demoapp1").await();
        System.out.println(resp.dataAsString());
    }
}
我们的赞助商

暂无...


成为赞助商