AMQP

Receiving messages from queues

No programming is needed to receive messages from AMQP queues. Create an AMQP definition and channel in Dashboard and a given service will be invoked for each message taken off a queue. The request will be in self.request.payload.

from zato.server.service import Service

class MyService(Service):

    def handle(self):
        self.logger.info('Message received: %s', self.request.payload)

Sending messages to exchanges

Create an AMQP definition and outgoing AMQP connection in Dashboard and send a message like in the example below.

from zato.server.service import Service

class MyService(Service):

    def handle(self):
        self.outgoing.amqp.send('my-message', 'outconn-name', '/exchange', 'route-key')