Getting Async Messages to work with tornado

13 views
Skip to first unread message

reduxdj

unread,
Jan 24, 2011, 11:20:17 PM1/24/11
to AmFast
1. I have a process that creates the Tornado IOLoop - I can call
messages with the test application and receive the callback
2. How do I send messages to channel with AsyncMessage

I am running this script called receive.py with pika, and AMQP,
however I can't write the messages to Flash, thanks:


#!/usr/bin/env python
import pika
from amfast.remoting import flex_messages
import logging
import optparse
import os
import sys
import pika
import tornado.httpserver
import tornado.ioloop

import amfast
from amfast.remoting.tornado_channel import ChannelSet,
TornadoChannelSet, TornadoChannel
connection = pika.AsyncoreConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')

print ' [*] Waiting for messages. To exit press CTRL+C'

def callback(ch, method, properties, body):
msg = flex_messages.AsyncMessage(headers=None,body="Hello World",
destination="messages",clientId=1)
channel_set = TornadoChannelSet(notify_connections=True)
channel_set.publishMessage(msg)
#channel_set.publishObject("Hello World", "topic-
name",sub_topic="sub-topic-name", headers=None, ttl=30000)
print " [x] Received %r" % (body,)

channel.basic_consume(callback,
queue='hello',
no_ack=True)

pika.asyncore_loop()

reduxdj

unread,
Jan 31, 2011, 9:11:04 AM1/31/11
to AmFast
I eventually got this to work with a project called stormed-amqp -
works great
Reply all
Reply to author
Forward
0 new messages