Skip to main content

A simple Python STOMP implementation with WebSocket support

Project description

webstompy

Documentation Status License: MIT Code style: black

This is webstompy, your friendly Python STOMP interface with WebSocket support. Currently, it supports version 1.1 of the STOMP specification.

Note: webstompy may not be feature-complete or respect the STOMP specification in full detail. It merely suffices our requirements. In case you observe non-standard behavior or missing functionality, feel free to leave an issue in the tracker or provide a pull request.

webstompy is aimed at simplicity of usage.

Documentation

Usage

Assuming you have a local RabbitMQ server with the Web STOMP Plugin running on port 15674 (see below how to set this up), the following example should work and produce a visible result:

from websocket import create_connection
import webstompy

class MyListener(webstompy.StompListener):
    def on_message(self, frame):
        print('Listener caught this frame: ', frame.payload)

ws_echo = create_connection('ws://127.0.0.1:15674/stomp/websocket')

connection = webstompy.StompConnection(connector=ws_echo)
connection.add_listener(MyListener())
connection.connect(login='guest', passcode='guest')
connection.send(destination='/topic/test', message='hello queue a')
connection.subscribe(destination='/topic/test', id='0')
connection.send(destination='/topic/test', message='hello queue b')

Logging

webstompy supports logging via the Python standard logging module. By default, it will just print the log levels WARINING and ERROR. You can control webstompy's logging in your app via

import logging
logging.getLogger("webstompy").setLevel(logging.CRITICAL)

Setup a local RabbitMQ demo

The above usage example can be realized using a RabbitMQ server with the Web STOMP Plugin. RabbitMQ acts as a broker, the example above in the end speaks with itself.

Install RabbitMQ with activated Web STOMP Plugin

Luckily, there is beevelop/rabbitmq-stomp, a Docker image for RabbitMQ with support for STOMP. Install it and run the RabbitMQ server:

docker pull beevelop/rabbitmq-stomp
docker run -d --name rabbit-stomp -p 15674:15674 beevelop/rabbitmq-stomp

Your RabbitMQ server WebSocket will listen on port 15674 and be available via http://127.0.0.1:15674/stomp.

License

MIT License, Copyright (c) 2020 Point 8 GmbH

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webstompy-0.1.3.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

webstompy-0.1.3-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file webstompy-0.1.3.tar.gz.

File metadata

  • Download URL: webstompy-0.1.3.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0

File hashes

Hashes for webstompy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2ab1082b41220e3c3d29d70080771ebd623b46fdb0c6c6113c1b3b91e732a0c7
MD5 7423058d9d4d685adac0348adb4c7cbd
BLAKE2b-256 2140512ef9fb419f31c3d7c657ea5f0c8ffc12803c0c4c4f37fdce8a9502ffce

See more details on using hashes here.

File details

Details for the file webstompy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: webstompy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0

File hashes

Hashes for webstompy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 761d1a8b5023b759c3e265658c6ca2ada7bbfeaa8b898186773aaa0f24c7671b
MD5 a11d8d6a343ba4091435cbb270c830ff
BLAKE2b-256 7d56790051fbebef92482ebd3e4cdecfb5aa51dd4e6cd8edcf662b07343bba6d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page