All Projects → juntossomosmais → django-stomp

juntossomosmais / django-stomp

Licence: MIT license
🔃 A simple implementation of STOMP with Django

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to django-stomp

Delphistompclient
STOMP client for Embarcadero Delphi and FreePascal.
Stars: ✭ 93 (+200%)
Mutual labels:  activemq, stomp
Activemq Artemis
Mirror of Apache ActiveMQ Artemis
Stars: ✭ 685 (+2109.68%)
Mutual labels:  activemq, stomp
rx-stomp
STOMP adaptor for RxJS
Stars: ✭ 76 (+145.16%)
Mutual labels:  activemq, stomp
Stomp Php
Stomp PHP Client
Stars: ✭ 94 (+203.23%)
Mutual labels:  activemq, stomp
learning-dome-code
分享日常java学习代码及用例,包括主流的框架、常用的组件、以及比较好的解决方案,项目会持续更新……
Stars: ✭ 58 (+87.1%)
Mutual labels:  activemq
Activemq
Mirror of Apache ActiveMQ
Stars: ✭ 1,970 (+6254.84%)
Mutual labels:  activemq
Activemq
activeMQ消息封装,主要解决:事务性消息、消息幂等性、异常造成的消息丢失问题 本项目不在更新,新项目请看ReliableMessageSystem: 本项目不再更新,新的版本迁移至ReliableMessageSystem 详情请看:https://github.com/zjpjohn/ReliableMeageSystem
Stars: ✭ 124 (+300%)
Mutual labels:  activemq
Jmstoolbox
Free universal JMS client
Stars: ✭ 119 (+283.87%)
Mutual labels:  activemq
fastapi-redis
Showcase of Redis integration with Python FastAPI framework as API backend for RDKit: Open-Source Cheminformatics Software
Stars: ✭ 46 (+48.39%)
Mutual labels:  pipenv
Review System Demo
A Spring Boot and AngularJS boilerplate project.
Stars: ✭ 18 (-41.94%)
Mutual labels:  activemq
ng-stomp
📑 STOMP for AngularJS
Stars: ✭ 42 (+35.48%)
Mutual labels:  stomp
Spring Boot Leaning
Spring Boot 2.X 最全课程代码
Stars: ✭ 2,008 (+6377.42%)
Mutual labels:  activemq
activemq-nms-api
Mirror of Apache ActiveMQ NMS API
Stars: ✭ 30 (-3.23%)
Mutual labels:  activemq
Activemq Apollo
Mirror of Apache ActiveMQ Apollo
Stars: ✭ 145 (+367.74%)
Mutual labels:  activemq
ng2-stompjs-demo
Angular 2 demo using stomp.js in Typescript
Stars: ✭ 42 (+35.48%)
Mutual labels:  stomp
Dubbo2.5 Spring4 Mybastis3.2 Springmvc4 Mongodb Redis
dubbo2.5-spring4-mybastis3.2-springmvc4-mongodb-redis整合
Stars: ✭ 123 (+296.77%)
Mutual labels:  activemq
Thunder
⚡️ Nepxion Thunder is a distribution RPC framework based on Netty + Hessian + Kafka + ActiveMQ + Tibco + Zookeeper + Redis + Spring Web MVC + Spring Boot + Docker 多协议、多组件、多序列化的分布式RPC调用框架
Stars: ✭ 204 (+558.06%)
Mutual labels:  activemq
activemq-website
Apache ActiveMQ Website
Stars: ✭ 16 (-48.39%)
Mutual labels:  activemq
Demo Project
存放学习过程中的demo项目,别光fork,顺便点下⭐哦
Stars: ✭ 198 (+538.71%)
Mutual labels:  activemq
Xbin Store
模仿国内知名B2C网站,实现的一个分布式B2C商城 使用Spring Boot 自动配置 Dubbox / MVC / MyBatis / Druid / Solr / Redis 等。使用Spring Cloud版本请查看
Stars: ✭ 2,140 (+6803.23%)
Mutual labels:  activemq

Django Stomp

Build Status Maintainability Test Coverage Code style: black Downloads Downloads Downloads PyPI version GitHub

A simple implementation of STOMP with Django.

In theory it can work with any broker which supports STOMP with none or minor adjustments.

Installation

pip install django_stomp

Add django_stomp in your INSTALLED_APPS and so be it.

Configuration process

Not yet fully available, but feel free to see our tests to get insights.

Consumer

First you must create a function which receives an parameter of type django_stomp.services.consumer.Payload. Let's suppose the module app.sample with the following content:

import logging

from django_stomp.services.consumer import Payload

logger = logging.getLogger(__name__)


def my_honest_logic(payload: Payload) -> None:
    logger.info("Yeah, I received a payload from django-stomp!")

    my_payload = payload.body
    my_header = payload.headers

    if my_payload.get("my-dict-key"):
        payload.ack()
    else:
        logger.info("To DLQ!")
        payload.nack()

Now you must provide broker connection details filling out the following parameters at least:

  • STOMP_SERVER_HOST
  • STOMP_SERVER_PORT
  • STOMP_USE_SSL

And just create the job issuing the following command:

python manage.py pubsub "/queue/your-stuff" app.sample.my_honest_logic

That's it ✌️

Settings

Here is a list of parameters that you can set in your Django project settings:

STOMP_SERVER_HOST

  The hostname of the STOMP server.

STOMP_SERVER_PORT

  The STOMP server port used to allow STOMP connections.

STOMP_SERVER_USER

  The client username to connect to a STOMP server.

STOMP_SERVER_PASSWORD

  The client password to connect to a STOMP server.

STOMP_USE_SSL

  Set to True, true, 1, T, t, Y or y in order to all STOMP connections use a SSL/TLS tunnel.

STOMP_SERVER_STANDBY_HOST

  The hostname of the STOMP standby server.

STOMP_SERVER_STANDBY_PORT

  The STOMP standby server port used to allow STOMP connections.

STOMP_SERVER_VHOST

  The virtual host used in the STOMP server.

STOMP_SUBSCRIPTION_ID

  Used to identify the subscription in the connection between client and server. See the STOMP protocol specification for more information.

STOMP_OUTGOING_HEARTBEAT

  A positive integer to indicates what is the period (in milliseconds) the client will send a frame to the server that indicates its still alive. Set to 0 to means that it cannot send any heart-beat frame. See the STOMP protocol specification for more information. Defaults to 10000 ms.

STOMP_INCOMING_HEARTBEAT

  A positive integer to indicates what is the period (in milliseconds) the client will await for a server frame until it assumes that the server is still alive. Set to 0 to means that it do not want to receive heart-beats. See the STOMP protocol specification for more information. Defaults to 10000 ms.

STOMP_WAIT_TO_CONNECT

  A positive integer to indicates how long it needs to await to try to reconnect if an Exception in the listener logic is not properly handled.

STOMP_DURABLE_TOPIC_SUBSCRIPTION

  Set to True, true, 1, T, t, Y or y in order to all STOMP topic subscription be durable. See the RabbitMQ take on it or the ActiveMQ for more information.

STOMP_LISTENER_CLIENT_ID

  A string that represents the client id for a durable subscriber or the listener prefix client id in a non-durable subscription in ActiveMQ.

STOMP_CORRELATION_ID_REQUIRED

  A flag that indicates if correlation-id header must be required or not. By default this flag is true (good practice thinking in future troubleshooting). Set to False, false, 0, F, f, N or n in order to allow consume messages without correlation-id header. If it's false django-stomp generates a correlation-id header for the message automatically.

STOMP_PROCESS_MSG_ON_BACKGROUND

  A flag to indicate if it should process a received message on background, enabling the broker-consumer communication to still take place. Set to True, true, 1, T, t, Y or y in order to have the message processing on background.

STOMP_PROCESS_MSG_WORKERS

  Optional parameter that controls how many workers the pool that manage the background processing should create. If defined, this parameter must be an integer!

STOMP_GRACEFUL_WAIT_SECONDS

  Optional parameter that controls how many seconds django-stomp will wait for a message to be processed. Defaults to 30 seconds. If defined, this parameter must be an integer!

Tests

In order to execute tests for ActiveMQ, execute the following:

docker-compose up -d broker-activemq

Or for RabbitMQ:

docker-compose up -d broker-rabbitmq

Then at last:

pipenv run tox

Database connection management (applies to version >= 5.0.0)

For every message that a django-stomp consumer receives, it opens a new DB connection if it needs to, keeping it open until it exceeds the maximum age defined by CONN_MAX_AGE or when the connection becomes unusable.

Known limitations

  • Currently, we assume that all dead lettered messages are sent to a queue with the same name as its original destination but prefixed with DLQ., i.e., if your queue is /queue/some-queue, the dead letter destination is asssumed to be /queue/DLQ.some-queue.
  • Be cautious with the heartbeat functionality! If your consumer is slow, it could prevent the client to receive and process any heart-beat frame sent by the server, causing the client to terminate the connection due to a false positive heartbeat timeout. You can workaround it with the STOMP_PROCESS_MSG_ON_BACKGROUND parameter that uses a thread pool to process the message.
  • For the RabbitMQ users: the django-stomp consumer always try to connect to a durable queue, so if your queue is not durable, the RabbitMQ broker will not allow the subscription.
  • For versions prior to 5.0.0: Any database connection management in the consumer side is up to its callback. If you have any long-running consumer that relies on a DB connection, be sure that you manage it properly, otherwise if a connection becomes unusable, you'll have to restart the consumer entirely just to setup a new DB connection.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].