Tutorial on sending AMQP messages using Python Zato, zatoamqp

Source: Internet
Author: User

Tutorial on sending AMQP messages using Python Zato, zatoamqp

This help topic shows the content required to use Zato to send AMQP messages. Zato is an enterprise service bus (ESB) for SOA, cloud integration, and backend services based on Python ).
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.