Tutorial on sending AMQP messages using Python Zato-Python tutorial

Source: Internet
Author: User
This article describes how to use Python's Zato to send AMQP messages. it is mainly based on some Zato graphical interfaces, for more information about how to use Zato to send AMQP messages, see the help topic. zato is an enterprise service bus (ESB) based on Python for SOA, cloud integration, and backend services ).
Code demo

The following code is required:

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 definition and connection

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

In your code, you only call a single. send method. you do not need to specify a specific URL or credential, message expiration time, content type, and so on. You can specify these parameters, but you do not need them.

All of this is achieved through connection definitions and real connections. The connection definition is a template that describes the details required to connect to the AMQP proxy-the proxy's network address, virtual host name, user name/password, and similar things. Each connection definition can be used to create one or more details-message priority, distribution mode, and other connections for processing the message to be sent.


The two object types can be created using the Zato Gui, or by using other methods such as enmasse or API.

Graphic Interface

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

All in all, after creating a new connection and writing a piece of code as shown above, you can hot deploy it to send AMQP messages.
Other configuration methods

On the contrary, you can also create, list, update, or delete AMQP connections by using the enmasse tool and API. It is not limited to graphical interfaces.
More examples

For more examples of using AMQP, see here.

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.