{ "info": { "author": "Ableton AG", "author_email": "webteam@ableton.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Domain event broker\n\nThis library provides a shallow layer on top of [RabbitMQ topic\nexchanges](https://www.rabbitmq.com/tutorials/tutorial-five-python.html) for\npublishing and receiving domain events. Publisher and subscriber need not know about\neach other and can be started and stopped in any order. Each subscriber controls\ntheir own retry policy, whether they need a durable queue for the time they are\ndown, or a dead-letter queue in case there is an error in the subscriber.\n\n## Configuration\n\nThis library needs to connect to RabbitMQ. By default, a local instance of\nRabbitMQ is used. This can be changed by passing an [amqp\nURL](http://pika.readthedocs.org/en/latest/examples/using_urlparameters.html)\nto `publish_domain_event` or when instantiating `Publisher` or `Subscriber`:\n\n from domain_event_broker import Subscriber\n subscriber = Subscriber('amqp://user:password@rabbitmq-host/domain-events')\n\n## Integrations\n\n### Django\n\nThis library can be configured via your Django settings. Add\n*domain_event_broker.django* to your `INSTALLED_APPS` and set the\n`DOMAIN_EVENT_BROKER` in your settings:\n\n INSTALLED_APPS = (\n 'domain_event_broker.django',\n )\n\n DOMAIN_EVENT_BROKER = 'amqp://user:password@rabbitmq-host/domain-events'\n\nMore information can be found in the\n[documentation](https://domain-event-broker.readthedocs.io/en/latest/django.html).\n\n## Sending events\n\nEvents can be sent by calling `publish_domain_event`:\n\n from domain_event_broker import publish_domain_event\n publish_domain_event('user.registered', {'user_id': user.id})\n\nDomain events are sent immediately. When emitting domain events from within a\ndatabase transaction, it's recommended to defer publishing until the transaction\nis committed. Using a commit hook avoids spurious domain events if a\ntransaction is rolled back after an error.\n\n## Receiving events\n\nSubscribers can listen to one or more domain events - controlled via the binding\nkeys. Binding keys may contain wildcards. A queue will be created for each\nsubscriber. RabbitMQ takes care of routing only the relevant events to this\nqueue.\n\nThis script will receive all events that are sent in the user domain:\n\n from domain_event_broker import Subscriber\n\n def log_user_event(event):\n print(event)\n\n subscriber = Subscriber()\n subscriber.register(log_user_event, 'printer', ['user.*'])\n subscriber.start_consuming()\n\n### Retry policy\n\nIf there is a problem consuming a message - for example a web service is down -\nthe subscriber can raise an error to retry handling the event after the given delay:\n\n from domain_event_broker import Subscriber\n\n def sync_user_data(event):\n try:\n publish_to_service(event)\n except ServiceIsDown:\n raise Retry(5.0 ** event.retries) # 1s, 5s, 25s\n\n subscriber = Subscriber()\n subscriber.register(sync_user_data, 'sync_data', ['user.*'], max_retries=3)\n subscriber.start_consuming()\n\nThe delayed retries are bound to the consumer, not the event. If `max_retries`\nis exceeded, the event will be dropped or dead-lettered.\n\n## Development\n\nMake sure you have RabbitMQ installed locally for testing.\n\n* Create virtualenv and activate it\n* Install dependencies with `pip install -r requirements.txt -r dev_requirements.txt -e .`\n* Run tests with `pytest`", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/AbletonAG/domain-event-broker", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "domain-event-broker", "package_url": "https://pypi.org/project/domain-event-broker/", "platform": "", "project_url": "https://pypi.org/project/domain-event-broker/", "project_urls": { "Homepage": "https://github.com/AbletonAG/domain-event-broker" }, "release_url": "https://pypi.org/project/domain-event-broker/2.0/", "requires_dist": null, "requires_python": "", "summary": "Send and receive domain events via RabbitMQ", "version": "2.0" }, "last_serial": 5114132, "releases": { "2.0": [ { "comment_text": "", "digests": { "md5": "9ff0afd48f8e3ece2c7f1f0104e18236", "sha256": "22cda410118a9e32e2f82ee6f06b619ff4143cf4c333a9c75a1dd685ad1ddb23" }, "downloads": -1, "filename": "domain-event-broker-2.0.tar.gz", "has_sig": false, "md5_digest": "9ff0afd48f8e3ece2c7f1f0104e18236", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30256, "upload_time": "2019-04-08T15:00:21", "url": "https://files.pythonhosted.org/packages/5e/4b/ea989303650c7e5b3d793b508d6859069732028f73cdf35c66fb64c233f2/domain-event-broker-2.0.tar.gz" } ], "2.0rc2": [ { "comment_text": "", "digests": { "md5": "c1facb1fc33f5beb8fafea8b6975f088", "sha256": "df26f86f2f73289605f50ca3a3b5172d62df388b77d2554ce5cc3c7c568aa086" }, "downloads": -1, "filename": "domain-event-broker-2.0rc2.tar.gz", "has_sig": false, "md5_digest": "c1facb1fc33f5beb8fafea8b6975f088", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28601, "upload_time": "2019-04-05T18:42:44", "url": "https://files.pythonhosted.org/packages/33/c2/9d4497aedfa4569c285d6808b2418c747913d8b7dd033527ec6c4ddd1a29/domain-event-broker-2.0rc2.tar.gz" } ], "2.0rc3": [ { "comment_text": "", "digests": { "md5": "7f20572896e09efce259b2ea623377b3", "sha256": "18c2f8560fb069054f4b4f25374281b67a39f23207beaa87a4cd1d3df2d30439" }, "downloads": -1, "filename": "domain-event-broker-2.0rc3.tar.gz", "has_sig": false, "md5_digest": "7f20572896e09efce259b2ea623377b3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28633, "upload_time": "2019-04-08T08:57:13", "url": "https://files.pythonhosted.org/packages/a3/1b/67dc3b78cb7961d465b09444c2c72c57de1eec628594a62ef412e89997df/domain-event-broker-2.0rc3.tar.gz" } ], "2.0rc4": [ { "comment_text": "", "digests": { "md5": "b200c064cc905d311f4c7789c1dc04a5", "sha256": "9f8905523e7f25d044362ace9120cbda3b119bb9769653ddb36e0b2a7718c336" }, "downloads": -1, "filename": "domain-event-broker-2.0rc4.tar.gz", "has_sig": false, "md5_digest": "b200c064cc905d311f4c7789c1dc04a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30303, "upload_time": "2019-04-08T09:03:24", "url": "https://files.pythonhosted.org/packages/bd/e6/4ed3569a3b5545f8e021fdcdb6a27cd31e7e599377309756ab925d529bfa/domain-event-broker-2.0rc4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9ff0afd48f8e3ece2c7f1f0104e18236", "sha256": "22cda410118a9e32e2f82ee6f06b619ff4143cf4c333a9c75a1dd685ad1ddb23" }, "downloads": -1, "filename": "domain-event-broker-2.0.tar.gz", "has_sig": false, "md5_digest": "9ff0afd48f8e3ece2c7f1f0104e18236", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30256, "upload_time": "2019-04-08T15:00:21", "url": "https://files.pythonhosted.org/packages/5e/4b/ea989303650c7e5b3d793b508d6859069732028f73cdf35c66fb64c233f2/domain-event-broker-2.0.tar.gz" } ] }