Bug fix, with router in transport class and actor hierarchy

community
Steve L. Nyemba 8 years ago
parent e3a0e6e8b0
commit 7423f6a9ec

@ -20,6 +20,10 @@ class Actor(Thread):
Thread.__init__(self) Thread.__init__(self)
self.config = config self.config = config
self.items = [] self.items = []
self.__id = config['id']
def getIdentifier(self):
return self.__id
def init(self,litems): def init(self,litems):
self.items = litems self.items = litems
def process(self,item): def process(self,item):
@ -33,8 +37,18 @@ class Actor(Thread):
pass pass
return stream return stream
def callback(self,channel,method,header,stream): def callback(self,channel,method,header,stream):
print stream print [self.getIdentifier(),stream]
#message = None
#try:
#message = json.loads(stream)
#except Exception, e:
#pass
#if message is not None:
#if 'id' in message :
#if 'payload' in message:
#self.execute(message['payload']
def run(self): def run(self):
info = {} info = {}
host = self.config['api'] host = self.config['api']
@ -68,4 +82,8 @@ class Alert(Actor):
config = {"id":"demo","key":"[0v8]-247&7!v3","api":"localhost"} config = {"id":"demo","key":"[0v8]-247&7!v3","api":"localhost"}
actor = Kill(config) actor = Kill(config)
actor.start() actor.start()
config = {"id":"demo-100","key":"[0v8]-247&7!v3","api":"localhost"}
actor_1 = Kill(config)
actor_1.start()

@ -410,7 +410,6 @@ class QueueReader(MessageQueue,Reader):
pass pass
#self.close() #self.close()
# r[qid].append( self.data) # r[qid].append( self.data)
return self.data return self.data
@ -419,10 +418,11 @@ class QueueListener(QueueReader):
properties = pika.ConnectionParameters(host=self.host) properties = pika.ConnectionParameters(host=self.host)
self.connection = pika.BlockingConnection(properties) self.connection = pika.BlockingConnection(properties)
self.channel = self.connection.channel() self.channel = self.connection.channel()
self.channel.exchange_declare(exchange=self.uid,type='fanout') self.channel.exchange_declare(exchange=self.uid,type='direct' )
self.info = self.channel.queue_declare(queue=qid,exclusive=True) self.info = self.channel.queue_declare(exclusive=True,queue=qid)
self.channel.queue_bind(exchange=self.uid,queue=self.info.method.queue) print self.info.method.queue
self.channel.queue_bind(exchange=self.uid,queue=self.info.method.queue,routing_key=qid)
#self.callback = callback #self.callback = callback
def read(self): def read(self):

Loading…
Cancel
Save