โ05-03-2024 03:25 PM
We have a customer looking to use Workato to connect to RAbbitMQ. Has anyone done that? Any pointers?
Thanks!
2 weeks ago
[Using Workato SDK and RabbitMQ API Documentation as Ref]
You can use Python:
import requests
import pika
import json
# RabbitMQ connection settings
rabbitmq_host = 'your-rabbitmq-host'
queue_name = 'your-queue-name'
# Workato Webhook URL
workato_webhook_url = 'https://hooks.workato.com/webhooks/<your-webhook-id>'
# RabbitMQ connection
connection = pika.BlockingConnection(pika.ConnectionParameters(host=rabbitmq_host))
channel = connection.channel()
channel.queue_declare(queue=queue_name)
# Message processing function
def callback(ch, method, properties, body):
message = json.loads(body)
# Send to Workato webhook
response = requests.post(workato_webhook_url, json=message)
print(f"Message sent to Workato: {response.status_code}")
channel.basic_consume(queue=queue_name, on_message_callback=callback, auto_ack=True)
print("Waiting for messages. To exit press CTRL+C")
channel.start_consuming()
---
This script:
1) Connects to RabbitMQ and listens to a queue.
2) Forwards any incoming messages to the Workato Webhook.