def start(self): if not self.haschannel("outgoing-messages"): self.addchannel(MessageQueue("outgoing-messages", self)) self.outgoing = self.getchannel("outgoing-messages") if self.dispatcher is None: self.dispatcher = dispatch.Dispatcher(self) self.dispatcher.start_dispatching() super(RemoteHost, self).start()
def start(self): for name in self.NAMES: if not self.haschannel(name): print "creating %r" % name self.addchannel(MessageQueue(name, self)) self.requests = self.getchannel("requests") self.responses = self.getchannel("responses") self.deadletters = self.getchannel("dead-letters") self.nodecommands = self.getchannel("node-commands") super(LocalHost, self).start()
queuehandler2 = Listener("Queue Listener 2", showcallback) topic = MessageTopic() topic.send(message1) print topic.messages.queue topic.attach(topichandler1) topic.send(message2) print topic.messages.queue topic.attach(topichandler2) topic.send(message3) print topic.messages.queue queue = MessageQueue("test-channel") queue.send(message1) print queue.messages.queue queue.send(message2) print queue.messages.queue print queue.receive() queue.attach(queuehandler1) print queue.messages.queue queue.send(message1) queue.send(message2) queue.send(message3) queue.send(message4) print queue.messages.queue
for x in range(1, len(queues)): thing = queues[x - 1].get() queues[x].put(thing) tstop = time.time() print "Took %0.3f seconds put/get %d things" % (tstop - tstart, i) # Took 9.897 seconds put/get 999 things import time from mpx.lib.message.types import Message from mpx.lib.messaging.channel.queue import MessageQueue Thing = Message() Thing.setheader("DEST", "//urchin/node-commands") channel = MessageQueue("Name") tstart = time.time() for i in xrange(1000): channel.send(Thing) thing = channel.receive() tstop = time.time() print "Took %0.3f seconds send/receive %d messages" % (tstop - tstart, i) # Took 1.052 seconds put/get 999 things import time from mpx.lib.message.data import SimpleMessage
queuehandler1 = Listener("Queue Listener 1", showcallback) queuehandler2 = Listener("Queue Listener 2", showcallback) topic = MessageTopic() topic.send(message1) print topic.messages.queue topic.attach(topichandler1) topic.send(message2) print topic.messages.queue topic.attach(topichandler2) topic.send(message3) print topic.messages.queue queue = MessageQueue("test-channel") queue.send(message1) print queue.messages.queue queue.send(message2) print queue.messages.queue print queue.receive() queue.attach(queuehandler1) print queue.messages.queue queue.send(message1) queue.send(message2) queue.send(message3) queue.send(message4) print queue.messages.queue
for i in xrange(1000): queues[0].put(Thing) for x in range(1, len(queues)): thing = queues[x - 1].get() queues[x].put(thing) tstop = time.time() print "Took %0.3f seconds put/get %d things" % (tstop - tstart, i) # Took 9.897 seconds put/get 999 things import time from mpx.lib.message.types import Message from mpx.lib.messaging.channel.queue import MessageQueue Thing = Message() Thing.setheader("DEST", "//urchin/node-commands") channel = MessageQueue("Name") tstart = time.time() for i in xrange(1000): channel.send(Thing) thing = channel.receive() tstop = time.time() print "Took %0.3f seconds send/receive %d messages" % (tstop - tstart, i) # Took 1.052 seconds put/get 999 things import time from mpx.lib.message.data import SimpleMessage from mpx.lib.messaging.channel.queue import MessageQueue Thing = SimpleMessage("Data") Thing.setheader("DEST", "//urchin/node-commands")
def callback(message): print "Callback(%s):\n%s\n" % (message, message.serialize()) def errback(message): print "Errback(%s):\n%s\n" % (message, message.serialize()) rna = as_node('/services/network/rna') rna.enabled = True rna.start() messaging = Messaging() messaging.configure({'name': 'messaging', 'parent': '/services'}) incoming = MessageQueue("//beggar/incoming", messaging) outgoing = MessageQueue("//beggar/outgoing", messaging) requests = MessageQueue("//beggar/requests", messaging) responses = MessageQueue("//beggar/responses", messaging) dead_letters = MessageQueue("//beggar/dead-letters", messaging) service_requests = MessageQueue("//beggar/service-requests", messaging) service_responses = MessageQueue("//beggar/service-responses", messaging) command_requests = MessageQueue("//beggar/node-commands", messaging) command_service = command.CommandService(command_requests, responses) command_service.configure({'name':'Command Service', 'parent': '/services/messaging'}) request_service = request.RequestService(requests, service_responses, dead_letters) request_service.configure({'name':'Request Service', 'parent': '/services/messaging'})