{"id":24973306,"url":"https://github.com/bluedynamics/zamqp","last_synced_at":"2025-03-29T06:13:00.590Z","repository":{"id":1228327,"uuid":"1158507","full_name":"bluedynamics/zamqp","owner":"bluedynamics","description":"AMQP broadcasting for python and zope.","archived":false,"fork":false,"pushed_at":"2011-03-15T15:10:44.000Z","size":116,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-03T18:38:38.146Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bluedynamics.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.rst","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-12-11T10:32:38.000Z","updated_at":"2013-12-09T23:02:51.000Z","dependencies_parsed_at":"2022-08-16T12:40:13.639Z","dependency_job_id":null,"html_url":"https://github.com/bluedynamics/zamqp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluedynamics%2Fzamqp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluedynamics%2Fzamqp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluedynamics%2Fzamqp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluedynamics%2Fzamqp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bluedynamics","download_url":"https://codeload.github.com/bluedynamics/zamqp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246145089,"owners_count":20730495,"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":[],"created_at":"2025-02-03T18:27:10.204Z","updated_at":"2025-03-29T06:13:00.568Z","avatar_url":"https://github.com/bluedynamics.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Overview\n========\n\n``zamqp`` is aimed to broadcast messages and trigger events between python\ninstances via AMQP.\n\nIt is based on amqplib and provides consumer and producer implementations as\nwell as a mechanism to trigger zope events remotely.\n\n\nHelper Classes\n--------------\n\nCreate properties for AMQP connection.\n::\n\n    \u003e\u003e\u003e from zamqp import AMQPProps\n    \u003e\u003e\u003e props = AMQPProps(host='localhost',\n    ...                   user='guest',\n    ...                   password='guest',\n    ...                   ssl=False,\n    ...                   exchange='zamqp.broadcast.fanout',\n    ...                   type='fanout',\n    ...                   realm='/data')\n\nCreate AMQP connection manually.\n::\n    \n    \u003e\u003e\u003e from zamqp import AMQPConnection\n    \u003e\u003e\u003e connection = AMQPConnection('zamqp_queue', props)\n\nAccess connection channel.\n::\n\n    \u003e\u003e\u003e connection.channel\n\n\nConsumer and producer\n---------------------\n\nCreate consumer callback.\n::\n\n   \u003e\u003e\u003e def callback(message):\n   ...     pass # do anything with received message here\n\nCreate and start consumer thread.\n::\n\n    \u003e\u003e\u003e from zamqp import AMQPConsumer\n    \u003e\u003e\u003e from zamqp import AMQPThread\n    \u003e\u003e\u003e consumer = AMQPConsumer('zamqp_queue', props, callback)\n    \u003e\u003e\u003e thread = AMQPThread(consumer)\n    \u003e\u003e\u003e thread.start()\n\nCreate producer and send a messages. Every python object which is serializable \ncan be used as a message.\n::\n\n    \u003e\u003e\u003e from zamqp import AMQPProducer\n    \u003e\u003e\u003e producer = AMQPProducer('zamqp_queue', props)\n    \u003e\u003e\u003e message = 'foo'\n    \u003e\u003e\u003e producer(message)\n\n\nTrigger events\n--------------\n\nCreate an event which should be triggered in the remote instance.\n::\n\n    \u003e\u003e\u003e class MyEvent(object):\n    ...     def __init__(self, name):\n    ...         self.name = name\n\nCreate a listener for ``MyEvent``. This gets called when AMQP events are\nreceived.\n::\n\n    \u003e\u003e\u003e def my_listener(event):\n    ...     if not isinstance(event, MyEvent):\n    ...         return\n    ...     # do something\n\n    \u003e\u003e\u003e import zope.event\n    \u003e\u003e\u003e zope.event.subscribers.append(my_listener) \n\nThe default ``AMQPEventCallback`` just calls ``zope.event.notify`` with the\nreceived payload, which is the serialized event, in this case an instance of\n``MyEvent``.\n\nStart our AMQP consumer for events.\n::\n\n    \u003e\u003e\u003e exchange = 'zamqp.events.fanout'\n    \u003e\u003e\u003e queue = 'zamqp_events'\n    \u003e\u003e\u003e from zamqp import AMQPEventCallback\n    \u003e\u003e\u003e props = AMQPProps(exchange=exchange)\n    \u003e\u003e\u003e callback = AMQPEventCallback()\n    \u003e\u003e\u003e consumer = AMQPConsumer(queue, props, callback)\n    \u003e\u003e\u003e thread = AMQPThread(consumer)\n    \u003e\u003e\u003e thread.start()\n    \nTrigger ``MyEvent`` to AMQP channel. The previously started event consumer now\nreceives this event and triggers it locally in it's own interpreter.\n::\n\n    \u003e\u003e\u003e from zamqp import AMQPEvent\n    \u003e\u003e\u003e event = AMQPEvent(queue, props, MyEvent('myevent'))\n    \u003e\u003e\u003e zope.event.notify(event)\n\nCredits\n=======\n\n  -Robert Niederreiter \u003crnix@squarewave.at\u003e\n\nChanges\n=======\n\n1.0b2\n-----\n\n- add runner module [rnix, 2010-12-11]\n\n1.0b1\n-----\n\n- make it work [rnix]","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluedynamics%2Fzamqp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluedynamics%2Fzamqp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluedynamics%2Fzamqp/lists"}