Skip to content

Instantly share code, notes, and snippets.

@remyleone
Created July 20, 2017 15:54
Show Gist options
  • Select an option

  • Save remyleone/0c59d192e98fa76ac8e086a66102519d to your computer and use it in GitHub Desktop.

Select an option

Save remyleone/0c59d192e98fa76ac8e086a66102519d to your computer and use it in GitHub Desktop.
import pika
import json
amqp_url = "amqp://P4O590UG:BHU4UOD3@finterop-mq.noc.onelab.eu:443/716e74a6-cecb-4839-8b16-04de2752cde6"
question = {
"_api_version": "0.1.32",
"_type": "testcoordination.step.verify.execute",
"description": "Please execute TD_COAP_CORE_01_v01_step_04",
"node": "coap_client",
"node_execution_mode": "user_assisted",
"response_type": "bool",
"step_id": "TD_COAP_CORE_01_v01_step_04",
"step_info": [
"Client displays the received information"
],
"step_state": "executing",
"step_type": "verify",
"testcase_id": "TBD",
"testcase_ref": "TBD"
}
# Open a connection to RabbitMQ on localhost using all default parameters
connection = pika.BlockingConnection(pika.URLParameters(amqp_url))
# Open the channel
channel = connection.channel()
# Declare the queue
channel.queue_declare(queue="test", durable=True, exclusive=False, auto_delete=False)
# Enabled delivery confirmations
channel.confirm_delivery()
# Send a message
if channel.basic_publish(exchange='default',
routing_key='control.testcoordination',
body=json.dumps(question),
properties=pika.BasicProperties(content_type='text/plain',
delivery_mode=1),
mandatory=True):
print 'Message was published'
else:
print 'Message was returned'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment