试用solace 消息平台
solace 是一个很不错的消息pubsub 平台,以下是一个简单的试用
启动
docker run -d -p 8080:8080 -p 55555:55555 -p:8008:8008 -p:1883:1883 -p:8000:8000 -p:5672:5672 -p:9000:9000 -p:2222:2222 --shm-size=2g --env username_admin_globalaccesslevel=admin --env username_admin_password=admin --name=solace solace/solace-pubsub-standard
端口说明
port 8080 — Use this port when configuring the message broker container with Solace PubSub+ Manager.
port 55555 — Your applications can use Solace APIs to connect to the message broker on this port.
port 8008 — The JavaScript sample applications below use this port to pass Web Messaging traffic through the message broker.
ports 1883 & 8000 — Ports for MQTT connectivity, over TCP and over WebSockets respectively
port 5672 — AMQP 1.0 applications using Apache QPID APIs would connect here
port 9000 — Use REST to send messaging and event data with Solace’s RESTful API port
port 2222 — Use SSH to connect to the Solace Command Line Interface (CLI) for advanced configuration
试用
测试下share subscription,
- package.json
{
"name": "client",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"mqtt": "^4.2.6"
},
"scripts": {
"app:app1": "node app.js",
"app:app2":"node app2.js",
"run-all":"npm-run-all --parallel app:**"
},
"devDependencies": {
"npm-run-all": "^4.1.5"
}
}
- app.js && app2.json
app.js
var mqtt = require('mqtt')
var client = mqtt.connect('mqtt://127.0.0.1')
client.on('connect', function () {
client.subscribe('$share/service1/dalongdemo', function (err) {
if (!err) {
client.publish('presence', 'Hello mqtt')
}
})
})
client.on('message', function (topic, message) {
// message is Buffer
console.log("app1")
console.log(message.toString())
})
app2.js
var mqtt = require('mqtt')
var client = mqtt.connect('mqtt://127.0.0.1')
client.on('connect', function () {
client.subscribe('$share/service1/dalongdemo', function (err) {
if (!err) {
client.publish('presence', 'Hello mqtt')
}
})
})
client.on('message', function (topic, message) {
// message is Buffer
console.log("app2")
console.log(message.toString())
})
- 运行
yarn run-all
- 发布消息
效果
参考资料
https://solace.com/products/event-broker/software/getting-started/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2019-11-30 testcontainers 方便的db测试框架
2019-11-30 tuned linux 性能调优工具
2019-11-30 streamsets 测试框架说明
2019-11-30 streamsets 源码构建
2018-11-30 hasura graphql-engine集成pgbouncer 连接池工具
2018-11-30 airflow-operator 可以管理airflow 的kuberntes 自定义controller && crd
2017-11-30 nomad 安装(单机)试用