消息中间件:Artemis#
功能介绍#
通过Artemis作为中间件接收第三方软件传输的消息数据并展示于Arkid平台
使用示例#
消息结构如下:注意用户ID列表中的ID需第三方软件以OIDC协议等方式向平台获取
{
"title": "消息标题",
"content": "消息内容",
"url": "跳转链接",
"users": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], #用户ID列表
}
import time
import sys
import json
import stomp
class MyListener(stomp.ConnectionListener):
def on_error(self,message):
print('received an error "%s"' % message)
def on_message(self, message):
print('received a message "%s"' % message)
hosts = [('your host', 61616)]
conn = stomp.Connection(host_and_ports=hosts)
conn.set_listener('', MyListener())
conn.connect('artemis', 'artemis', wait=True, headers={"client-id":"arkid"})
data = {
"title": "消息标题",
"content": "消息内容",
"url": "跳转链接",
"users": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"], #用户ID列表
"sender":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # 发送者ID
}
conn.send(body=json.dumps(data), destination='your destination')
time.sleep(2)
conn.disconnect()