collective / collective.zamqp

AMQP-integration for Zope2
https://pypi.python.org/pypi/collective.zamqp
Other
3 stars 2 forks source link

.. image:: https://travis-ci.org/collective/collective.zamqp.png :target: http://travis-ci.org/collective/collective.zamqp

AMQP integration for Zope2 (and Plone)

collective.zamqp acts as a Zope Server by co-opting Zope's asyncore mainloop (using asyncore-supporting AMQP-library pika <http://pypi.python.org/pypi/pika>_), and injecting consumed messages as requests to be handled by ZPublisher (exactly like Zope ClockServer).

Therefore AMQP-messages are handled (by default) in a similar environment to regular HTTP-requests: ZCA-hooks, events and everything else behaving normally.

This package is an almost complete rewrite of affinitic.zamqp <http://pypi.python.org/pypi/affinitic.zamqp>_, but preserves its ideas on how to setup AMQP-messaging by configuring only producers and consumers.

TODO

While we are still documenting and testing collective.zamqp, you may want to take a look at collective.zamqpdemo <http://github.com/datakurre/collective.zamqpdemo/>_ for an example of use.

Installation

A common setup includes a producer and a worker instance which are both connected to the same rabbitmq server.

Buildout

Both instances can be easily configured using buildout::

[buildout]
parts =
    instance
    worker

...

[instance]
recipe = plone.recipe.zope2instance
http-address = 8080
eggs =
    ...
    collective.zamqp

...
zope-conf-additional =
    %import collective.zamqp
    <amqp-broker-connection>
        connection_id   superuser
        hostname        my.rabbithostname.com
        port            5672
        username        guest
        password        guest
        heartbeat       120
        keepalive       60
    </amqp-broker-connection>

[worker]
<= instance
http-address = 8081
zserver-threads = 1
environment-vars =
    ZAMQP_LOGLEVEL INFO
zope-conf-additional =
    ${instance:zope-conf-additional}
    <amqp-consuming-server>
        connection_id   superuser
        site_id         Plone
        user_id         admin
    </amqp-consuming-server>

Explanation of configuration parameters

Configuring logging

You may want to in/decrease collective.zamqp loglevel which can easily be done by passing an environment variable into worker instance as seen in buildout example above::

[worker]
...
environment-vars =
    ZAMQP_LOGLEVEL INFO
...

Valid parameters are: