作一个体验最简单的开源消息中间件
支持Qos0、定时、过期、顺序、广播、事务、二进制等消息特性。有确认、重试、延时等机制。可嵌入、单机、集群等部署。
//server
docker run -p 18602:18602 -p 8602:8602 noearorg/folkmq-broker:1.7.8
Java
Kotlin
JavaScript
Python
//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.topic", message -> {
System.out.println(message);
});
//发布
client.publish("demo.topic", new MqMessage("helloworld!"));
}
}
//client
fun main(args: Array) {
//客户端
val client = FolkMQ.createClient("folkmq://127.0.0.1:18602")
.nameAs("demoapp")
.connect()
//订阅
client.subscribe("demo.topic") { message ->
console.log(message)
})
//发布
client.publish("demo.topic", MqMessage("helloworld!"))
}
//client
async function main() {
//客户端(服务端需要启用 ws 协议)
const client = await FolkMQ.createClient("folkmq:ws://127.0.0.1:18603")
.nameAs("demoapp")
.connect();
//订阅
client.subscribe("demo.topic", null, true, message => {
console.log(message);
});
//发布
client.publish("demo.topic", FolkMQ.newMessage("helloworld!"));
}
main();
#client
async def main():
#客户端(服务端需要启用 ws 协议)
client = await (FolkMQ.create_client("folkmq:ws://127.0.0.1:18603")
.name_as("demoapp")
.connect())
#订阅
await client.subscribe("demo.topic", lambda message:
log.info(message)
)
#发布
await client.publish("demo.topic", MqMessage("helloworld!"))
if __name__ == "__main__":
asyncio.run(main())
黄金赞助商 (我也要赞助)