Package: anyblok_bus
AnyBlok / busImproveAnyBlokto add comunication with bus.BlokDependanciesDescriptionbusConsume and publish message withpikaandmarshmallowAnyBlok / Bus is released under the terms of theMozilla Public License.See thelatest documentationContentsAnyBlok / busUsageDeclare a new consumerPublish a message through rabbitmqFront MatterProject HomepageInstallationUnit TestScriptDependenciesAuthorContributorsBugsCHANGELOG1.2.0 (2019-06-24)1.1.0 (2018-09-15)1.0.0 (2018-06-05)UsageDeclare a new consumerIn an AnyBlok Model you have to decorate a method withbus_consumerfrom  anyblok_bus import bus_consumer
from anyblok import Declarations
from .schema import MySchema

@Declarations.register(Declarations.Model)
class MyModel:

    @bus_consumer(queue_name='name of the queue', schema=MySchema())
    def my_consumer(cls, body):
        # do somethingThe schema must be an instance of marshmallow.Schema,see the marshmallow documentationNoteThe decorated method become a classmethod with always the same prototype (cls, body)
body is the desarialization of the message from the queue by the schema.Publish a message through rabbitmqThe publication is done byregistry.Bus.publishmethod:registry.Bus.publish('exchange', 'routing_key', message, mimestype)if the message have not be send, then an exception is raised..warning:A profile must be defined and selected by the AnyBlok configuration **bus_profile**Front MatterInformation about the AnyBlok / Bus project.Project HomepageAnyBlok is hosted ongithub- the main project
page is athttps://github.com/AnyBlok/anyblok_bus. Source code is
tracked here usingGIT.Releases and project status are available on Pypi athttp://pypi.python.org/pypi/anyblok_bus.The most recent published version of this documentation should be athttp://doc.anyblok-bus.anyblok.org.InstallationInstall released versions of AnyBlok from the Python package index withpipor a similar tool:pip install anyblok_busInstallation via source distribution is via thesetup.pyscript:python setup.py installInstallation will add theanyblokcommands to the environment.Unit TestRun the test withnose:pip install nose
nosetests anyblok_bus/testsScriptanyblok_bus addconsole_scriptto launch worker. A worker consume a queue defined
by the decoratoranyblok_bus.bus_consumer:anyblok_bus -c anyblok_config_file.cfg..note:: The profile name in the configuration is used to find the correct url to connect to rabbitmqDependenciesAnyBlok / Bus works withPython >= 3.4and later andpika >= 1.0.1. The install process will
ensure thatAnyBlokis installed, in addition to other
dependencies. The latest version of them is strongly recommended.AuthorJean-Sébastien SuzanneContributorsAnyboxteam:Jean-Sébastien SuzanneFlorent JouatteSenseeteam:Julien SZKUDLAPSKIJean-Sébastien SuzanneBugsBugs and feature enhancements to AnyBlok should be reported on theIssue
tracker.ContentsAnyBlok / busUsageDeclare a new consumerPublish a message through rabbitmqFront MatterProject HomepageInstallationUnit TestScriptDependenciesAuthorContributorsBugsCHANGELOG1.2.0 (2019-06-24)1.1.0 (2018-09-15)1.0.0 (2018-06-05)CHANGELOG1.2.0 (2019-06-24)Update version to use pika >= 1.0.1Fixed Multiple consumer on the same modelRefactored bus console script, Added processes parameter on bus_consumer.
The goal is to define processes for one queue, by default all the queues
are in the same processAdd better logging when a queue is missing. If a queue is missing, then
workers won’t start.Added adapter parameter to transform bus message, the schema attribute
become now a simple kwargs argument give to adapter.The adapter is not required.NoteTo keep the compatibility, if no adapter is defined with a schema then
the adapter is schema_adapter1.1.0 (2018-09-15)Improved logging: for helping to debug the messagesAdded create and update date columnsfixedconsume_allmethod. now the method does not stop when an exception is raisedUsed marsmallow version >= 3.0.01.0.0 (2018-06-05)add Worker to consume the message from rabbitmqadd publish method to publish a message to rabbitmqaddanyblok_bus.bus_consumeradd decorator to défine the consumer