Tutorials for sending AMQP messages using Python's Zato

Source: Internet
Author: User
This Help topic shows what you need to use Zato to send AMQP messages. Zato is a python-based enterprise service Bus (ESB) for SOA, cloud-Sing woo backend services.
Code Demo

Here are some of the required code:

From Zato.server.service Import Service

Class MyService (Service):
def handle (self):
msg = ' My message '
Conn_name = ' My CRM connection '
Exchange_name = ' My exchange '
Routing_key = ' '
Self.outgoing.amqp.send (msg, Conn_name, Exchange_name, Routing_key)


Understanding Connection Definitions and connections

Before sending the first message, you must let Zato know where to send the message, because by default Zato supports separating the service that generated the message and the actual destination of the message delivery.

In your code, you just call a single. Send method, and you don't really need to specify a specific URL or credential, message expiration time, content type, and so on. You can specify these, but you don't need them.

All of this is done through connection definitions and real connections. A connection definition is a template that describes the details required to connect to the AMQP agent-the network address of the proxy, the virtual hostname, the username/password, and something like that. Each connection definition can be used to create one or more connections that handle the details of the message to be sent-message priority, distribution mode, and other message information.


Both of these object types can be created using the Zato graphical interface, or by other means such as Enmasse or API.

Graphical interface

First create a connection definition, and then use it to create an external connection, as shown in:

In summary, after creating a new connection and writing the code shown earlier, you can send the AMQP message in a hot deployment.
Other ways to configure

Instead, alternatively, use the Enmasse tool and API to create, list, update, or delete AMQP connections. is not limited to graphical interface methods.
More examples of Use

Please see the full API and more examples of AMQP usage here.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.