{"id":26096294,"url":"https://github.com/juntossomosmais/django-stomp","last_synced_at":"2025-04-06T18:13:35.204Z","repository":{"id":34908464,"uuid":"188899678","full_name":"juntossomosmais/django-stomp","owner":"juntossomosmais","description":"🔃 A simple implementation of STOMP with Django","archived":false,"fork":false,"pushed_at":"2024-12-08T08:28:32.000Z","size":588,"stargazers_count":37,"open_issues_count":10,"forks_count":4,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-03-30T17:08:20.431Z","etag":null,"topics":["activemq","django","pipenv","python","rabbitmq","stomp","stomp-client"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juntossomosmais.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-27T19:38:20.000Z","updated_at":"2024-09-09T12:25:43.000Z","dependencies_parsed_at":"2024-09-09T14:33:51.559Z","dependency_job_id":"24fa4204-49f0-4af2-9503-e437053ed225","html_url":"https://github.com/juntossomosmais/django-stomp","commit_stats":{"total_commits":242,"total_committers":13,"mean_commits":"18.615384615384617","dds":0.628099173553719,"last_synced_commit":"c97e1fa77ca346d31ba128d1f80a6950ceda5ba4"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juntossomosmais%2Fdjango-stomp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juntossomosmais%2Fdjango-stomp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juntossomosmais%2Fdjango-stomp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juntossomosmais%2Fdjango-stomp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juntossomosmais","download_url":"https://codeload.github.com/juntossomosmais/django-stomp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526753,"owners_count":20953143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activemq","django","pipenv","python","rabbitmq","stomp","stomp-client"],"created_at":"2025-03-09T14:37:03.480Z","updated_at":"2025-04-06T18:13:35.183Z","avatar_url":"https://github.com/juntossomosmais.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Stomp\n\n[![Build Status](https://dev.azure.com/juntos-somos-mais-loyalty/python/_apis/build/status/django-stomp?branchName=master)](https://dev.azure.com/juntos-somos-mais-loyalty/python/_build/latest?definitionId=23\u0026branchName=master)\n[![Maintainability](https://sonarcloud.io/api/project_badges/measure?project=juntossomosmais_django-stomp\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=juntossomosmais_django-stomp)\n[![Test Coverage](https://sonarcloud.io/api/project_badges/measure?project=juntossomosmais_django-stomp\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=juntossomosmais_django-stomp)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n[![Downloads](https://pepy.tech/badge/django-stomp)](https://pepy.tech/project/django-stomp)\n[![Downloads](https://pepy.tech/badge/django-stomp/month)](https://pepy.tech/project/django-stomp/month)\n[![Downloads](https://pepy.tech/badge/django-stomp/week)](https://pepy.tech/project/django-stomp/week)\n[![PyPI version](https://badge.fury.io/py/django-stomp.svg)](https://badge.fury.io/py/django-stomp)\n[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/juntossomosmais/django-stomp/blob/master/LICENSE)\n\nA simple implementation of STOMP with Django.\n\nIn theory it can work with any broker which supports STOMP with none or minor adjustments.\n\n## Installation\n\n`pip install django_stomp`\n\nAdd `django_stomp` in your `INSTALLED_APPS` and so be it.\n\n## Configuration process\n\nNot yet fully available, but feel free to see our tests to get insights.\n\n### Consumer\n\nFirst 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:\n\n```python\nimport logging\n\nfrom django_stomp.services.consumer import Payload\n\nlogger = logging.getLogger(__name__)\n\n\ndef my_honest_logic(payload: Payload) -\u003e None:\n    logger.info(\"Yeah, I received a payload from django-stomp!\")\n\n    my_payload = payload.body\n    my_header = payload.headers\n\n    if my_payload.get(\"my-dict-key\"):\n        payload.ack()\n    else:\n        logger.info(\"To DLQ!\")\n        payload.nack()\n```\n\nNow you must provide broker connection details filling out the following parameters at least:\n\n- STOMP_SERVER_HOST\n- STOMP_SERVER_PORT\n- STOMP_USE_SSL\n\nAnd just create the job issuing the following command:\n\n```bash\npython manage.py pubsub \"/queue/your-stuff\" app.sample.my_honest_logic\n```\n\nThat's it ✌️\n\n### Settings\n\nHere is a list of parameters that you can set in your Django project settings:\n\n***STOMP_SERVER_HOST***\n\n  The hostname of the STOMP server.\n\n***STOMP_SERVER_PORT***\n\n  The STOMP server port used to allow STOMP connections.\n\n***STOMP_SERVER_USER***\n\n  The client username to connect to a STOMP server.\n\n***STOMP_SERVER_PASSWORD***\n\n  The client password to connect to a STOMP server.\n\n***STOMP_USE_SSL***\n\n  Set to ``True, true, 1, T, t, Y or y`` in order to all STOMP connections use a SSL/TLS tunnel.\n\n***STOMP_SERVER_STANDBY_HOST***\n\n  The hostname of the STOMP standby server.\n\n***STOMP_SERVER_STANDBY_PORT***\n\n  The STOMP standby server port used to allow STOMP connections.\n\n***STOMP_SERVER_VHOST***\n\n  The virtual host used in the STOMP server.\n\n***STOMP_SUBSCRIPTION_ID***\n\n  Used to identify the subscription in the connection between client and server. See the [STOMP protocol specification\n](https://stomp.github.io/stomp-specification-1.1.html#SUBSCRIBE_id_Header) for more information.\n\n***STOMP_OUTGOING_HEARTBEAT***\n\n  A positive integer to indicates what is the period (in milliseconds) the client will send a frame to the server\nthat indicates its still alive. Set to ``0`` to means that it cannot send any heart-beat frame. See the [STOMP\nprotocol specification](https://stomp.github.io/stomp-specification-1.1.html#Heart-beating) for more information.\nDefaults to 10000 ms.\n\n***STOMP_INCOMING_HEARTBEAT***\n\n  A positive integer to indicates what is the period (in milliseconds) the client will await for a server frame until\nit assumes that the server is still alive. Set to ``0`` to means that it do not want to receive heart-beats. See\nthe [STOMP protocol specification](https://stomp.github.io/stomp-specification-1.1.html#Heart-beating) for more\ninformation. Defaults to 10000 ms.\n\n***STOMP_WAIT_TO_CONNECT***\n\n  A positive integer to indicates how long it needs to await to try to reconnect if an `Exception` in the listener\nlogic is not properly handled.\n\n***STOMP_DURABLE_TOPIC_SUBSCRIPTION***\n\n  Set to ``True, true, 1, T, t, Y or y`` in order to all STOMP topic subscription be durable. See the [RabbitMQ](\nhttps://www.rabbitmq.com/stomp.html#d.dts) take on it or the\n[ActiveMQ](https://activemq.apache.org/how-do-durable-queues-and-topics-work) for more information.\n\n***STOMP_LISTENER_CLIENT_ID***\n\n  A string that represents the client id for a durable subscriber or the listener prefix client id in a non-durable\nsubscription in ActiveMQ.\n\n***STOMP_CORRELATION_ID_REQUIRED***\n\n  A flag that indicates if `correlation-id` header must be required or not. By default this flag is true (good practice\nthinking in future troubleshooting).\nSet to ``False, false, 0, F, f, N or n`` in order to allow consume messages without `correlation-id` header. If it's\nfalse `django-stomp` generates a correlation-id header for the message automatically.\n\n***STOMP_PROCESS_MSG_ON_BACKGROUND***\n\n  A flag to indicate if it should process a received message on background, enabling the broker-consumer communication\nto still take place.\n  Set to ``True, true, 1, T, t, Y or y`` in order to have the message processing on background.\n\n***STOMP_PROCESS_MSG_WORKERS***\n\n  Optional parameter that controls how many workers the pool that manage the background processing should create. If\ndefined, this parameter **must** be an integer!\n\n***STOMP_GRACEFUL_WAIT_SECONDS***\n\n  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!\n\n***STOMP_DEFAULT_EXCLUSIVE_QUEUE***\n\n  Optional parameter that defines if the default value of `exclusive` queue parameter will be True or False when creating a queue in RabbitMQ. The default value is `False`.\n\n## Tests\n\nIn order to execute tests for ActiveMQ, execute the following:\n```bash\ndocker-compose up -d broker-activemq\n```\n\nOr for RabbitMQ:\n```bash\ndocker-compose up -d broker-rabbitmq\n```\n\nThen at last:\n```bash\npipenv run tox\n```\n\n## Database connection management (applies to version \u003e= 5.0.0)\n\nFor 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.\n\n## Known limitations\n\n- Currently, we assume that all dead lettered messages are sent to a queue with the same name as its original\ndestination but prefixed with `DLQ.`, i.e., if your queue is `/queue/some-queue`, the dead letter destination is\nasssumed to be `/queue/DLQ.some-queue`.\n- **Be cautious with the heartbeat functionality**! If your consumer is slow, it could prevent the client to receive\nand process any `heart-beat` frame sent by the server, causing the client to terminate the connection due to a false\npositive heartbeat timeout. You can workaround it with the `STOMP_PROCESS_MSG_ON_BACKGROUND` parameter that uses a\nthread pool to process the message.\n- For the RabbitMQ users: the **django-stomp consumer** always try to connect to a\n[durable queue](https://www.rabbitmq.com/queues.html#durability), so if your queue is not durable, the RabbitMQ broker\nwill not allow the subscription.\n- **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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuntossomosmais%2Fdjango-stomp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuntossomosmais%2Fdjango-stomp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuntossomosmais%2Fdjango-stomp/lists"}