代码拉取完成,页面将自动刷新
同步操作将从 noear/folkmq 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
一个内存型消息中间件(支持快照持久化、Broker 集群),目前为预览阶段
//使用 MacBook pro 2020 + JDK8 本机测试,单客户端发与收(跑分难免有波动,我是选了好看点的)
QQ交流群:316697724 | 微信交流群(申请时输入:FolkMQ) |
---|---|
镜像 | 说明 |
---|---|
noearorg/folkmq-server:1.0.10 | 服务端(主端口:8602,消息端口:18602) |
noearorg/folkmq-broker:1.0.10 | 服务端(主端口:8602,消息端口:18602) |
当使用 broker 集群时,把 folkmq-server 端口改成:8601
属性或环境变量 | 默认值 | |
---|---|---|
server.port |
8602 | 主端口(http,管理用) |
18602 | 消息端口(tcp),等于主端口+10000 | |
folkmq.admin |
admin | 管理密码 |
添属性或环境变量,例: folkmq.access.ak1=sk1
,folkmq.access.ak2=sk2
docker run -p 18602:18602 -p 8602:8602 noearorg/folkmq-server:1.0.10
<dependencies>
<!-- 可选包:java-tcp(90kb左右), smartsocket(260Kb左右), netty(2.5Mb左右) -->
<dependency>
<groupId>org.noear</groupId>
<artifactId>folkmq-transport-java-tcp</artifactId>
<version>1.0.10</version>
</dependency>
</dependencies>
public class ClientDemo1 {
public static void main(String[] args) throws Exception {
//客户端(鉴权为可选。服务端,不添加则不鉴权)
MqClient client = FolkMQ.createClient("folkmq://127.0.0.1:18602?ak=folkmq&sk=YapLHTx19RlsEE16")
.connect();
//订阅(consumer = ip or cluster name)
client.subscribe("demo", "demoapp", message -> {
System.out.println(message);
});
//发布
client.publish("demo", "helloworld!").get();
}
}
派发次数 | 自动延时 | |
---|---|---|
0 | 0s | 相当于马上发 |
1 | 5s | |
2 | 30s | |
3 | 3m | |
4 | 9m | |
5 | 15m | |
6 | 30m | |
7 | 1h | |
n.. | 2h | 第8次之后都是2小时 |
//消息客户端接口
public interface MqClient {
//连接
MqClient connect() throws IOException;
//断开连接
void disconnect() throws IOException;
//客户端配置
MqClient config(ClientConfigHandler configHandler);
//自动回执
MqClient autoAcknowledge(boolean auto);
//订阅主题
void subscribe(String topic, String consumer, MqConsumeHandler consumerHandler) throws IOException;
//取消订阅主题
void unsubscribe(String topic, String consumer) throws IOException;
//发布消息
default CompletableFuture<?> publish(String topic, String content) throws IOException {
return publish(topic, content, null, 1);
}
//发布消息
default CompletableFuture<?> publish(String topic, String content, int qos) throws IOException {
return publish(topic, content, null, qos);
}
//发布消息
default CompletableFuture<?> publish(String topic, String content, Date scheduled) throws IOException {
return publish(topic, content, scheduled, 1);
}
//发布消息
CompletableFuture<?> publish(String topic, String content, Date scheduled, int qos) throws IOException;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。