Python实现基于WebSocket的stomp协议调试助手工具

stomp协议很简单,但是搜遍网络竟没找到一款合适的客户端工具。大多数提供的都是客户端库的使用。可能是太简单了吧!可是即便这样,假如有一可视化的工具,将方便的对stomp协议进行抓包调试。网上类似MQTT的客户端工具有很多,但是stomp协议调试工具很少,这里使用Python和websocket实现stomp协议的调试工具,分享给有需要的小伙伴。 

STOMP 协议简介

STOMP(Simple Text Oriented Messaging Protocol)是一种简单的文本消息传递协议,设计用于与消息中间件进行交互。它允许客户端通过多种编程语言与消息代理(如ActiveMQ, RabbitMQ等)进行通信。STOMP 协议的特点包括:

简单:协议设计简洁,易于实现。

跨平台:支持多种编程语言和操作系统。

灵活:支持多种消息模式,如发布/订阅、请求/响应等。

工具下载地址:https://download.csdn.net/download/qq8864/89916303

直接使用WebSocket(或SockJS)就很类似于使用TCP套接字来编写Web应用。因为没有高层级的线路协议,因此就需要我们定义应用之间所发送消息的语义,还需要确保连接的两端都能遵循这些语义。

就像HTTP在TCP套接字之上添加了请求-响应模型层一样,STOMP在WebSocket之上提供了一个基于帧的线路格式(frame-based wire format)层,用来定义消息的语义。

与HTTP请求和响应类似,STOMP帧由命令、一个或多个头信息以及负载所组成。例如,如下就是发送数据的一个STOMP帧:

>>> SEND
transaction:tx-0
destination:/app/marco
content-length:20{"message":"Marco!"}

它是一个基于帧的协议,它的帧结构模仿了 HTTP。一个帧由命令、一组可选header和一个可选body组成。STOMP 是基于文本的,但也允许传输二进制消息。STOMP 的默认编码是 UTF-8,但它支持为消息主体指定备用编码。 

STOMP 报文格式

STOMP 报文由命令、头信息和消息体组成,格式如下:

COMMAND
header1:value1
header2:value2message-body
NULL

COMMAND:表示操作类型,如 CONNECT, SEND, SUBSCRIBE 等。

header1:value1:头信息,用于传递额外的信息。

message-body:消息体,可选部分。

NULL:报文结束标志,用 \x00 表示。  

基于 WebSocket 实现 STOMP 

WebSocket 是一种在单个 TCP 连接上进行全双工通信的协议。通过 WebSocket,可以实现实时的数据交换。结合 STOMP 协议,可以构建高效的实时消息系统。

核心类设计

Stomp 类

Stomp 类负责管理与 STOMP 服务器的连接、订阅和发送消息等操作。

class Stomp:def __init__(self, host, sockjs=False, wss=True):self.url = "ws://" + host if not wss else "wss://" + hostself.dispatcher = Dispatcher(self)self.callback_registry = {}self.on_error = Noneself.on_connect = Noneself.on_message = Noneself.on_close = Nonedef connect(self, username=None, passcode=None):self.connected = Falseself.dispatcher.connect(username, passcode)start_time = time.time()timeout = 10while not self.connected:if time.time() - start_time > timeout:print("Connection timed out")return Falsetime.sleep(0.5)if self.on_connect:self.on_connect(self.connected)return self.connecteddef disconnect(self):self.dispatcher.ws.close()self.connected = Falseif self.on_close:self.on_close()def subscribe(self, destination, id=None, ack='auto', callback=None):if callback:self.callback_registry[destination] = callbackself.dispatcher.subscribe(destination, id, ack)def send(self, destination, message):self.dispatcher.send(destination, message)

Dispatcher 类

Dispatcher 类负责处理 WebSocket 的连接、消息收发和帧的解析。 

class Dispatcher:def __init__(self, stomp):self.stomp = stompself.ws = websocket.WebSocketApp(self.stomp.url)self.ws.on_open = self._on_openself.ws.on_message = self._on_messageself.ws.on_error = self._on_errorself.ws.on_close = self._on_closeself.ws.on_ping = self._on_pingThread(target=self.ws.run_forever, kwargs={'ping_interval': 10, 'ping_timeout': 8}).start()self.opened = Falsewhile not self.opened:time.sleep(0.5)def _on_message(self, ws, message):print("<<< " + message)command, headers, body = self._parse_message(message)if command == "CONNECTED":self.stomp.connected = Trueif command == "MESSAGE" and headers['destination'] in self.stomp.callback_registry:self.stomp.callback_registry[headers['destination']](body)if command != '' and self.stomp.on_message:self.stomp.on_message(command, headers, body)def _on_error(self, ws, error):print(error)if self.stomp.on_error:self.stomp.on_error(error)def _on_close(self, ws, code, reason):print("### closed ###")if self.stomp.on_close:self.stomp.on_close(code, reason)def _on_open(self, ws):self.opened = Truedef _on_ping(self, ws, message):print("### ping ###")def _transmit(self, command, headers, msg=None):lines = [command + BYTE['LF']]for key in headers:lines.append(key + ":" + headers[key] + BYTE['LF'])lines.append(BYTE['LF'])if msg:lines.append(msg)lines.append(BYTE['NULL'])frame = ''.join(lines)print(">>>" + frame)self.ws.send(frame)def _parse_message(self, frame):lines = frame.split(BYTE['LF'])command = lines[0].strip()headers = {}i = 1while lines[i] != '':key, value = lines[i].split(':')headers[key] = valuei += 1body = None if i >= len(lines) - 1 else ''.join(lines[i+1:len(lines)-1]).replace('\x00', '')return command, headers, bodydef connect(self, username=None, passcode=None):headers = {HDR_HOST: '/', HDR_ACCEPT_VERSION: VERSIONS, HDR_HEARTBEAT: '10000,10000'}if username:headers[HDR_LOGIN] = usernameif passcode:headers[HDR_PASSCODE] = passcodeself._transmit(CMD_CONNECT, headers)def subscribe(self, destination, id, ack):headers = {HDR_ID: id or str(uuid.uuid4()), CMD_ACK: ack, HDR_DESTINATION: destination}self._transmit(CMD_SUBSCRIBE, headers)def send(self, destination, message):headers = {HDR_DESTINATION: destination, HDR_CONTENT_LENGTH: str(len(message))}self._transmit(CMD_SEND, headers, msg=message)def ack(self, message_id, subscription):headers = {'id': message_id, 'subscription': subscription}self._transmit(CMD_ACK, headers)

界面工具实现

tkinter是python自带的标准gui库,对于我们自己日常做一些小程序出来给自己使用是非常不错的。因为tkinter相比较其它强大的gui库(PyQT,WxPython等等)而言要简单、方便、学起来也容易得很多,所以用来造个小工具非常nice,但它做出来的界面不是很好看。

ttkbootstrap 介绍

ttkbootstrap 是一个基于 tkinter 和 ttk 的Python库,它提供了一套现代化的主题和样式,可以用于创建漂亮的图形用户界面(GUI)应用程序。它是基于 Bootstrap 框架的设计风格,为 tkinter 应用程序提供了一致的外观和用户体验。

需要先安装依赖包:

pip install ttkbootstrap
pip install -i https://pypi.doubanio.com/simple websocket-client
# -*- coding: utf-8 -*-
# @Time : 2023/09/17 12:49
# @Author : yangyongzhen
# @Email : 534117529@qq.com
# @File : stompclienttool.py
# @Project : study
import time
import os
from tkinter.ttk import *
from tkinter import *
from datetime import datetime
from tkinter import messagebox
from ttkbootstrap import Style
#import stomp
import json
#import websocket
from PIL import Image, ImageTk
import stomp_wsglobal gui  # 全局型式保存GUI句柄tx_cnt = 0  # 发送条数统计
rx_cnt = 0  # 接收条数统计class GUI:def __init__(self):self.root = Tk()self.root.title('STOMP调试助手-author:blog.csdn.net/qq8864')  # 窗口名称self.root.geometry("820x560+500+150")  # 尺寸位置self.root.resizable(False, False)self.interface()Style(theme='pulse')self.isConnect = Falseself.client = Nonedef interface(self):""""界面编写位置"""# 操作区域self.fr1 = Frame(self.root)self.fr1.place(x=0, y=0, width=220, height=600)  # 区域1位置尺寸img_path = os.path.join(os.path.dirname(__file__), 'me.png')img = Image.open(img_path)  # 替换为你的图片路径img = img.resize((80, 80))self._img = ImageTk.PhotoImage(img)self.about = Label(self.fr1)self.about.image = self._imgself.about.configure(image=self._img)self.about.place(x=65, y=0, width=80, height=80)pos = 80self.lb_server = Label(self.fr1, text='地址:', anchor="e", fg='red')self.lb_server.place(x=0, y=pos, width=50, height=35)self.txt_server = Text(self.fr1)self.txt_server.place(x=65, y=pos, width=155, height=28)self.txt_server.insert("1.0", "ws://localhost:15674/ws")  # WebSocket 地址self.lb_port = Label(self.fr1, text='clientID:', anchor="e", fg='red')self.lb_port.place(x=0, y=pos + 40, width=50, height=35)self.txt_id = Text(self.fr1)self.txt_id.place(x=65, y=pos + 40, width=155, height=28)self.txt_id.insert("1.0", "stomp-client")self.lb_user = Label(self.fr1, text='用户名:', anchor="e", fg='red')self.lb_user.place(x=0, y=pos + 80, width=50, height=35)self.txt_name = Text(self.fr1)self.txt_name.place(x=65, y=pos + 80, width=155, height=28)self.txt_name.insert("1.0", "guest")self.lb_pwd = Label(self.fr1, text='密码:', anchor="e", fg='red')self.lb_pwd.place(x=0, y=pos + 120, width=50, height=35)self.txt_pwd = Text(self.fr1)self.txt_pwd.place(x=65, y=pos + 120, width=155, height=28)self.txt_pwd.insert("1.0", "guest")self.var_bt1 = StringVar()self.var_bt1.set("连接")self.btn1 = Button(self.fr1, textvariable=self.var_bt1, command=self.btn_connect)self.btn1.place(x=170, y=pos + 160, width=50, height=30)self.lb_s = Label(self.fr1, text='订阅主题', bg="yellow", anchor='w')self.lb_s.place(x=5, y=340, width=90, height=28)self.txt_sub = Text(self.fr1)self.txt_sub.place(x=5, y=368, width=155, height=28)self.btn5 = Button(self.fr1, text='订阅', command=self.btn_sub)self.btn5.place(x=170, y=368, width=50, height=28)self.subitem = Listbox(self.fr1)self.subitem.place(x=5, y=402, width=215, height=85)self.subitem.bind("<Button-3>", self.on_right_click)# 文本区域self.fr2 = Frame(self.root)self.fr2.place(x=220, y=0, width=620, height=560)self.txt_rx = Text(self.fr2)self.txt_rx.place(relheight=0.6, relwidth=0.9, relx=0.05, rely=0.01)self.scrollbar = Scrollbar(self.txt_rx)self.scrollbar.pack(side=RIGHT, fill=Y)self.txt_rx.config(yscrollcommand=self.scrollbar.set)self.scrollbar.config(command=self.txt_rx.yview)self.txt_rx.bind("<Configure>", self.check_scrollbar)self.lb_t = Label(self.fr2, text='发布主题', bg="yellow", anchor='w')self.lb_t.place(relheight=0.04, relwidth=0.2, relx=0.05, rely=0.62)self.txt_topic = Text(self.fr2)self.txt_topic.place(relheight=0.05, relwidth=0.9, relx=0.05, rely=0.66)self.txt_tx = Text(self.fr2)self.txt_tx.place(relheight=0.15, relwidth=0.9, relx=0.05, rely=0.72)self.btn3 = Button(self.fr2, text='清空',command = self.txt_clr) #绑定清空方法self.btn4 = Button(self.fr2, text='保存',command=self.savefiles) #绑定保存方法self.btn3.place(relheight=0.06,relwidth=0.11,relx=0.05,rely=0.88)self.btn4.place(relheight=0.06,relwidth=0.11,relx=0.18,rely=0.88)self.btn6 = Button(self.fr2, text='发送', command=self.btn_send)self.btn6.place(relheight=0.06, relwidth=0.11, relx=0.84, rely=0.88)self.lb3 = Label(self.fr2, text='接收:0    发送:0', bg="yellow", anchor='w')self.lb3.place(relheight=0.05, relwidth=0.3, relx=0.045, rely=0.945)def check_scrollbar(self, *args):if self.txt_rx.yview() == (0.0, 1.0):self.scrollbar.pack_forget()else:self.scrollbar.place(RIGHT, fill=Y)def on_right_click(self, w):idx = self.subitem.curselection()if idx == ():returnselected_item = self.subitem.get(idx)ret = messagebox.askyesno('取消订阅', "取消订阅:\n" + selected_item)if ret:self.subitem.delete(idx)self.client.unsubscribe(selected_item)self.appendTxt("取消订阅:" + selected_item)def gettim(self):#获取时间 未用timestr = time.strftime("%H:%M:%S")  # 获取当前的时间并转化为字符串self.lb4.configure(text=timestr)  # 重新设置标签文本# tim_str = str(datetime.datetime.now()) + '\n'# self.lb4['text'] = tim_str#self.lb3['text'] = '接收:'+str(rx_cnt),'发送:'+str(tx_cnt)self.txt_rx.after(1000, self.gettim)     # 每隔1s调用函数 gettime 自身获取时间 GUI自带的定时函数def txt_clr(self):#清空显示self.txt_rx.delete(0.0, 'end')  # 清空文本框self.txt_tx.delete(0.0, 'end')  # 清空文本框def tx_rx_cnt(self,rx=0,tx=0):  #发送接收统计global tx_cntglobal rx_cntrx_cnt += rxtx_cnt += txself.lb3['text'] = '接收:'+str(rx_cnt),'发送:'+str(tx_cnt)def savefiles(self):   #保存日志TXT文本try:with open('log.txt','a') as file:       #a方式打开 文本追加模式file.write(self.txt_rx.get(0.0,'end'))messagebox.showinfo('提示', '保存成功')except:messagebox.showinfo('错误', '保存日志文件失败!')def log_callback(self,client, userdata, level, buf):print(buf)def is_valid_json(self,json_str):"""判断字符串是否是有效的 JSONArgs:json_str (str): 需要判断的字符串Returns:bool: 如果字符串是有效的 JSON,则返回 True,否则返回 False"""if json_str is None:return Falsetry:json.loads(json_str)return Trueexcept ValueError:return Falsedef appendTxt(self, msg, flag=None):current_t = datetime.now()current_ = current_t.strftime("%Y-%m-%d %H:%M:%S ")self.txt_rx.insert(END, current_)self.txt_rx.insert(END, msg)self.txt_rx.insert(END, "\n")self.txt_rx.see(END)self.txt_rx.update_idletasks()def connect(self, ws_url, user, password):# 将 ws_url 分解成 (host, port) 形式的元组if ws_url.startswith("ws://"):ws_url = ws_url[5:]elif ws_url.startswith("wss://"):ws_url = ws_url[6:]else:raise ValueError("Invalid WebSocket URL")self.client =stomp_ws.Stomp(ws_url, sockjs=False, wss=False)self.client.on_connect = self.on_connectself.client.on_message = self.on_messageself.client.on_error = self.on_errorself.client.on_close = self.on_closeself.isConnect = self.client.connect(user,password)return self.isConnectdef on_connect(self, rc):if rc == True:print("Connected to Stomp Broker ok!\n")self.appendTxt("Connected to Stomp Broker ok!\n")self.var_bt1.set("断开")self.isConnect = Trueelse:print("Failed to connect, return code %d\n", rc)self.appendTxt(f"Failed to connect\n")self.isConnect = Falsedef on_message(self, cmd,header, body):self.tx_rx_cnt(1,0)print("Received message: \n" + str(header))header = json.loads(str(header).replace("'", '"'))header = json.dumps(header, indent=4, sort_keys=True, separators=(',', ': '), ensure_ascii=False)if(self.is_valid_json(body)):body = json.loads(str(body).replace("'", '"'))body = json.dumps(body, indent=4, sort_keys=True, separators=(',', ': '), ensure_ascii=False)self.appendTxt(f"Received message:\n[Cmd]:{cmd}\n[Header]:\n{header}\n[Body]:\n{body}\n","RECV")def on_error(self, error):self.appendTxt(f"发生错误: {error}")def on_close(self,code,reason):self.isConnect = Falseself.var_bt1.set("连接")self.subitem.delete(0, END)self.appendTxt("WebSocket连接已关闭,code="+ str(code) +',reason='+reason)def btn_connect(self):  # 连接if self.var_bt1.get() == '连接':server = self.txt_server.get("1.0", END).strip()user = self.txt_name.get("1.0", END).strip()psd = self.txt_pwd.get("1.0", END).strip()ws_url = server  # WebSocket 地址print(f"连接到 {ws_url},用户名: {user}")self.appendTxt(f"连接到 {ws_url},用户名: {user}")if self.connect(ws_url, user, psd):self.var_bt1.set("断开")else:self.client.disconnect()self.var_bt1.set("连接")self.isConnect = Falseself.appendTxt("断开连接!")def btn_sub(self):  # 订阅if self.isConnect:sub = self.txt_sub.get("1.0", END).strip()self.client.subscribe(destination=sub, ack='auto')self.appendTxt(f"已订阅主题: {sub}")self.subitem.insert(END, sub)else:messagebox.showinfo('提示', '服务器未连接!')def btn_send(self):  # 发布if self.isConnect:pub_topic = self.txt_topic.get("1.0", END).strip()payload = self.txt_tx.get("1.0", END).strip()self.client.send(destination=pub_topic,message=payload)self.appendTxt(f"发布到 {pub_topic}: {payload}")self.tx_rx_cnt(0,1)else:messagebox.showinfo('提示', '请连接服务器!')if __name__ == '__main__':print('Start...')gui = GUI()gui.root.mainloop()print('End...')

完整代码

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: jenny
# datetime: 2021/5/6 15:53 
# File :stomp_ws.py
import websocket
import time
from threading import Thread
import uuid
from constants import *
BYTE = {'LF': '\x0A','NULL': '\x00'
}VERSIONS = '1.0,1.1'class Stomp:def __init__(self, host, sockjs=False, wss=True):"""Initialize STOMP communication. This is the high level API that is exposed to clients.Args:host: Hostnamesockjs: True if the STOMP server is sockjswss: True if communication is over SSL"""# websocket.enableTrace(True)ws_host = host if sockjs is False else host + "/websocket"protocol = "ws://" if wss is False else "wss://"self.url = protocol + ws_hostprint("websocket url:"+self.url)self.dispatcher = Dispatcher(self)# maintain callback registry for subscriptions -> topic (str) vs callback (func)self.callback_registry = {}self.on_error = Noneself.on_connect = Noneself.on_message = Noneself.on_close = Nonedef connect(self,username=None,passcode=None):"""Connect to the remote STOMP server"""# set flag to falseself.connected = False# attempt to connectself.dispatcher.connect(username,passcode)# wait until connectedstart_time = time.time()timeout = 10  # 10 secondswhile self.connected is False:if time.time() - start_time > timeout:print("Connection timed out")return Falsetime.sleep(.50)if self.on_connect is not None:self.on_connect(self.connected)return self.connecteddef disconnect(self):"""Disconnect from the remote STOMP server"""        self.dispatcher.ws.close()self.connected = Falseif self.on_close is not None:self.on_close()def subscribe(self, destination,id=None,ack='auto',callback=None):"""Subscribe to a destination and supply a callback that should be executed when a message is received on that destination"""# create entry in registry against destinationif callback is not None:self.callback_registry[destination] = callback# transmit subscribe frameself.dispatcher.subscribe(destination,id,ack)def send(self, destination, message):"""Send a message to a destination"""self.dispatcher.send(destination, message)class Dispatcher:def __init__(self, stomp):"""The Dispatcher handles all network I/O and frame marshalling/unmarshalling"""self.stomp = stomp#websocket.enableTrace(True)  # 开启调试信息self.ws = websocket.WebSocketApp(self.stomp.url)self.ws.ping_interval = 30self.ws.ping_timeout = 10# register websocket callbacksself.ws.on_open = self._on_openself.ws.on_message = self._on_messageself.ws.on_error = self._on_errorself.ws.on_close = self._on_closeself.ws.on_ping = self._on_ping# run event loop on separate threadThread(target=self.ws.run_forever,kwargs={'ping_interval': 10, 'ping_timeout': 8}).start()self.opened = False# wait until connectedwhile self.opened is False:time.sleep(.50)def _on_message(self, ws, message):"""Executed when messages is received on WS"""print("<<< " + message)if len(message) > 0:command, headers, body = self._parse_message(message)# if connected, let Stomp knowif command == "CONNECTED":self.stomp.connected = True# if message received, call appropriate callbackif command == "MESSAGE":# 检查字典中是否存在该主题的回调函数if headers['destination'] in self.stomp.callback_registry:self.stomp.callback_registry[headers['destination']](body)# if message is acked, let Stomp knowif command == CMD_ACK:print("ACK: " + headers['id'])if command != '':if self.stomp.on_message is not None:self.stomp.on_message(command, headers, body)def _on_error(self, ws, error):"""Executed when WS connection errors out"""print(error)if self.stomp.on_error is not None:self.stomp.on_error(error)def _on_close(self,ws,code,reason):"""Executed when WS connection is closed"""print("### closed ###")if self.stomp.on_close is not None:self.stomp.on_close(code,reason)def _on_open(self, ws):"""Executed when WS connection is opened"""self.opened = Truedef _on_ping(self,ws,message):print("### ping ###")def _transmit(self, command, headers, msg=None):"""Marshalls and transmits the frame"""# Contruct the framelines = []lines.append(command + BYTE['LF'])# add headersfor key in headers:lines.append(key + ":" + headers[key] + BYTE['LF'])lines.append(BYTE['LF'])# add message, if anyif msg is not None:lines.append(msg)# terminate with null octetlines.append(BYTE['NULL'])frame = ''.join(lines)# transmit over wsprint(">>>" + frame)self.ws.send(frame)def _parse_message(self, frame):"""Returns:commandheadersbodyArgs:frame: raw frame string"""lines = frame.split(BYTE['LF'])command = lines[0].strip()headers = {}# get all headersi = 1while lines[i] != '':# get key, value from raw header(key, value) = lines[i].split(':')headers[key] = valuei += 1# set body to None if there is no bodyif i < len(lines) - 1:body = None if lines[i+1] == BYTE['NULL'] else  ''.join(lines[i+1:len(lines)-1])if body is not None:body = body.replace('\x00', '')else:body = Nonereturn command, headers, bodydef connect(self,username=None,passcode=None):"""Transmit a CONNECT frame"""headers = {}headers[HDR_HOST] = '/'headers[HDR_ACCEPT_VERSION] = VERSIONSheaders[HDR_HEARTBEAT] = '10000,10000'if username is not None:headers[HDR_LOGIN] = usernameif passcode is not None:headers[HDR_PASSCODE] = passcodeself._transmit(CMD_CONNECT, headers)def subscribe(self,destination,id,ack):"""Transmit a SUBSCRIBE frame"""headers = {}# TODO id should be auto generatedif id is None:id = str(uuid.uuid4())headers[HDR_ID] = idheaders[CMD_ACK] = ackheaders[HDR_DESTINATION] = destinationself._transmit(CMD_SUBSCRIBE, headers)def send(self, destination, message):"""Transmit a SEND frame"""headers = {}headers[HDR_DESTINATION] = destinationheaders[HDR_CONTENT_LENGTH] = str(len(message))self._transmit(CMD_SEND, headers, msg=message)def ack(self, message_id, subscription):"""Transmit an ACK frameACK 命令用于确认消息已成功处理当客户端接收到消息时,消息的头部会包含 message-id 字段。客户端需要从这个字段中提取 message_id在订阅消息时,客户端会指定一个 id,这个 id 就是 subscription"""headers = {}headers['id'] = message_idheaders['subscription'] = subscriptionself._transmit(CMD_ACK, headers)def do_thing_a(msg):print("MESSAGE: " + msg)def main(url,*sub_topic, **send_topic):stomp = Stomp(url, sockjs=False, wss=True)stomp.connect()stomp.subscribe(sub_topic, do_thing_a)time.sleep(2)stomp.send(send_topic, '{"name":"akshaye"}')
if __name__ == "__main__":main()

测试使用

前提条件:装有RabbitMQ并配置开启支持stomp协议支持,提供Broker服务。

以RabbitMQ为例子:关于RabbitMQ的安装,参见:RabbitMQ最新版本4.0.2在Windows下的安装及使用-CSDN博客

工具下载地址:https://download.csdn.net/download/qq8864/89916303

其他资源

https://github.com/jasonrbriggs/stomp.py

快速开始 | EMQX 企业版 4.3 文档

STOMP Over WebSocket

Fitten Code

https://github.com/rabbitmq/rabbitmq-server

https://www.rabbitmq.com/docs/install-windows#installer

python网络编程之websocket - 简书

【stomp实战】Stomp协议介绍和客户端的使用-CSDN博客

STOMP协议1.2_stomp1.2-CSDN博客

websocket_client教程:Python中的WebSocket客户端实战-CSDN博客

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/457106.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux shell 脚本语言教程(超详细!)

Shell 编程详细指南 什么是 Shell&#xff1f; Shell 是用户与操作系统内核之间的接口&#xff0c;允许用户通过命令行输入来控制操作系统。它充当命令解释器&#xff0c;读取用户输入的命令并执行相应的操作。Shell 提供了强大的脚本编程能力&#xff0c;可以自动化许多任务…

【javax maven项目缺少_Maven的依赖管理 引入依赖】

javax maven项目缺少_Maven的依赖管理 引入依赖 Maven的依赖管理 - 引入依赖依赖管理(引入依赖)导入依赖 https://blog.csdn.net/weixin_28932089/article/details/112381468 Maven的依赖管理 - 引入依赖 依赖管理(引入依赖) 能够掌握依赖引入的配置方式 导入依赖 导入依赖练…

银行客户贷款行为数据挖掘与分析

#1024程序员节 | 征文# 在新时代下&#xff0c;消费者的需求结构、内容与方式发生巨大改变&#xff0c;企业要想获取更多竞争优势&#xff0c;需要借助大数据技术持续创新。本文分析了传统商业银行面临的挑战&#xff0c;并基于knn、逻辑回归、人工神经网络三种算法&#xff0…

重构案例:将纯HTML/JS项目迁移到Webpack

我们已经了解了许多关于 Webpack 的知识&#xff0c;但要完全熟练掌握它并非易事。一个很好的学习方法是通过实际项目练习。当我们对 Webpack 的配置有了足够的理解后&#xff0c;就可以尝试重构一些项目。本次我选择了一个纯HTML/JS的PC项目进行重构&#xff0c;项目位于 GitH…

[旧日谈]高清画面撕裂问题考

背景 无边框透明背景透明的窗口&#xff0c;在随着缩放比例非整数倍数放大时的画面发生了露底、撕裂问题。 当我们在使用Qt开发的时候&#xff0c;遇到了一个结构性问题。因为我们的软件是自己做的&#xff0c;所以要自己定义标题栏&#xff0c;所以我们设置了软件为FrameLess…

mono源码交叉编译 linux arm arm64全过程

初级代码游戏的专栏介绍与文章目录-CSDN博客 我的github&#xff1a;codetoys&#xff0c;所有代码都将会位于ctfc库中。已经放入库中我会指出在库中的位置。 这些代码大部分以Linux为目标但部分代码是纯C的&#xff0c;可以在任何平台上使用。 源码指引&#xff1a;github源…

mysql——事务详解

一、事务定义 事务&#xff1a;事务是一个最小的不可在分的工作单元&#xff1b;通常一个事务对应一个完整的业务(例如银行账户转账业务&#xff0c;该业务是一个最小的工作单元)事务保证多条sql语句要么同时执行成功&#xff0c;要么同时执行失败一个完整的业务需要批量的DML…

移除Microsoft Edge浏览器“由你的组织管理“提示的方法

背景&#xff1a; 点击Microsoft Edge浏览器右上角的按钮有时候会出现提示“由你的组织管理”。但实际上自己的电脑并没有被公司或其他企业管理。 解决方案&#xff1a; 提示&#xff1a;修改注册表如果操作不当会影响电脑&#xff0c;请提前备份注册表&#xff01;&#xff…

Java 开发——(上篇)从零开始搭建后端基础项目 Spring Boot 3 + MybatisPlus

一、概述 记录时间 [2024-10-23] 本文是一个基于 Spring Boot 3 MybatisPlus 的项目实战开发&#xff0c;主要涵盖以下几个方面&#xff1a; 从零开始的项目创建IDEA 中开发环境的热部署Maven、Swagger3、MybatisPlus 等的配置路由映射知识静态资源访问文件上传功能实现拦截器…

Qt之QCamera的简单使用

文章目录 一、相机操作相关示例1.摄像头操作内容使用示例2.摄像头信息展示使用示例3.摄像头设置切换、预览操作示例 二、相机使用个人操作理解1.相机类支持信息获取2.相机类曝光、焦点、图像处理控制信息获取3.快速启动相机设置&#xff08;各个设备处于理想状态&#xff09; 三…

地平线x5下运行yolo11s-seg模型

经过地瓜机器人工作人员&#xff08;感谢吴超同学&#xff09;的及时技术支持&#xff0c;整体比较顺利的跑起来了yolo11s-seg分割模型。将一些经验记录下来&#xff1a; 首先下载使用docker镜像&#xff1a; https://developer.d-robotics.cc/forumDetail/228559182180396619 …

linux驱动—注册总线分析

成功地在直接注册了一个总线&#xff0c;并且在总线目录下创建了属性文件&#xff0c;什么会在 sys/bus 目录下生成 mybus,目录以及对应的 devices,drivers, drivers_autoprobe,drivers_probe&#xff0c;uevent目录和属性呢? /sys,目录下的目录都对应一个kobject&#xff0c;…

如何成为录屏高手?2024年全新录屏工具梳理,你选对了吗?

如何录屏&#xff1f;录屏现在对我们来说太重要了&#xff0c;不管是做教学视频、演示文稿&#xff0c;还是录游戏或者教别人怎么用软件&#xff0c;都离不开录屏工具。但是市面上录屏软件一大堆&#xff0c;挑个适合自己的真不容易。今天&#xff0c;我就来给你介绍几款特别火…

知识图谱解码:AI 如何构建知识网络

大家好&#xff0c;我是Shelly&#xff0c;一个专注于输出AI工具和科技前沿内容的AI应用教练&#xff0c;体验过300款以上的AI应用工具。关注科技及大模型领域对社会的影响10年。关注我一起驾驭AI工具&#xff0c;拥抱AI时代的到来。 AI工具集1&#xff1a;大厂AI工具【共23款…

凸轮应用实例(带进料装置的伺服压机控制)

凸轮表凸轮关系曲线建立 博途S7-1500T PLC曲柄连杆模型仿真(电子凸轮完整配置+SCL源代码)-CSDN博客文章浏览阅读4次。这篇博客介绍了曲柄连杆机构的位移与曲柄转动角度关系,通过MATLAB进行计算和Simulink验证,并提供博途SCL源代码。文章链接提供了详细的曲柄连杆数学模型分析…

分布式理论基础

文章目录 1、理论基础2、CAP定理1_一致性2_可用性3_分区容错性4_总结 3、BASE理论1_Basically Available&#xff08;基本可用&#xff09;2_Soft State&#xff08;软状态&#xff09;3_Eventually Consistent&#xff08;最终一致性&#xff09;4_总结 1、理论基础 在计算机…

WASM 使用说明23事(RUST实现)

文章目录 1. wasm是什么1.1 chatgpt定义如下:1.2 wasm关键特性&#xff1a; 2. wasm demo2.1 cargo 创建项目2.2 编写code2.3 安装wasm-pack2.4 编译 3.1 html页面引用wasm代码&#xff08;js引用&#xff09;3.2 访问页面4 导入js function4.1 编写lib.rs文件&#xff0c;内容…

【SpringCloud】06-Sentinel

1. 雪崩问题 一个微服务出现问题导致一系列微服务都不可以正常工作。 服务保护方案&#xff1a; 请求限流。线程隔离。 服务熔断 2. Sentinel 启动Sentinel java -Dserver.port8090 -Dcsp.sentinel.dashboard.serverlocalhost:8090 -Dproject.namesentinel-dashboard -ja…

【已解决】C# NPOI如何在Excel文本中增加下拉框

前言 上图&#xff01; 解决方法 直接上代码&#xff01;&#xff01;&#xff01;&#xff01;综合了各个大佬的自己修改了一下&#xff01;可以直接规定在任意单元格进行设置。 核心代码方法块 #region Excel增加下拉框/// <summary>/// 增加下拉框选项/// </s…

centeros7 编译ffmpeg

使用yum安装的路似乎已经堵住了&#xff0c;请求的镜像全是404或503 1.打开终端并使用yum安装EPEL存储库(Extra Packages for Enterprise Linux)&#xff1a;sudo yum install epel-release2.接下来&#xff0c;使用以下命令来安装FFmpeg&#xff1a;sudo yum install ffmpeg …