Test admin
Test admin

Reputation: 731

Trying to publish messages to rabbit mq server

This isn't working

#!/usr/bin/python

import pika

credentials = pika.PlainCredentials('user', 'user')

parameters = pika.ConnectionParameters('rabbitmqqa2.server.com',
                                   15672,
                                   '/',
                                   credentials)

connection = pika.BlockingConnection(parameters)

channel = connection.channel()

channel.queue_declare(queue='zabbix-mail')

message = 'Python Queue - Message Sent from sender.py {N|T}'

channel.basic_publish(exchange='zabbix',
                      routing_key='zabbix-mail-route',
                      body=message)
print(" [x] Sent 'Hello World!'")

connection.close()

Upvotes: 0

Views: 987

Answers (1)

Ambika
Ambika

Reputation: 594

As You've not mentioned error, I can advise you to check following points.

  1. is rabbitmq working on connected machine ?
  2. you are using port 15672 but default port for sending message is 5672
  3. default credentials (username,password) of rabbitmq is "guest" and "guest" respectively.
  4. Since you are not declaring exchange or binding to queue, you should manually make them from rabbitmq panel ( by default running on 15672)

Upvotes: 1

Related Questions