I have a service that is invoked by ESB (zato) the role of this service is to publish a message in rabbitMQ through an AMQP outgoing but when i consult rabbitMQ and make get message the answer is queue is empty.this is service in zato
from zato.server.service import Service
class HelloService(Service):
def handle(self):
# Request parameters
msg = 'Hello AMQP broker!'
out_name = 'My CRM connection'
exchange = 'My exchange'
routing_key = ''
properties = {'app_id': 'ESB'}
headers = {'X-Foo': 'bar'}
# Send a message to the broker
self.outgoing.amqp.send(msg, out_name, exchange, routing_key,
properties, headers)
A full working example to consume from a rabbit queue from a zato service would be as follows:
In rabbit
The first three steps can be done in multiple ways, here is a simple python script you can use to do that (just install kombu, and click):
And the settings file:
Now lets create the queues running the above script on a fresh virtualenv with python 2.7:
copy the scripts above
and run create_queues.py.
You can verify the exchanges and queues are on rabbit with the cli tool or with the management plugin:
Now the zato part (Steps 4,5 and 6) can be done using the public api, or the webadmin, I'll show you how to do it with the public api, but is easier to do it trough the UI as this is only done very few times.
Create AMQP Connection Definition doc
Set Password for our AMQP Connection doc
Create an outgoing AMQP connection defintion doc
Finally the service that is going to send the message
If you are going to use the properties user_id it must match the connection user_id or else the request will fail.
Also please note that here I've created a deadletter exchange and the message will be sent here after 30 seconds if its still in the
test.service.request
queueThe final step is to test
To verify that the message is delivered to our queue, we can create an http/soap channel or invoke the service directly, I'm doing the latter using the public api.
and after that we check the queue for the message we just sent:
Remember to check the rabbit and zato server logs in case you still have any problem.