def __call__(self): """ Trigger pulled. Execute the request. """ if not self._pending: raise Exception('trigger already executed') self._pending = False # asynchronous if self._policy.reply: return self._send(reply=self._policy.reply) if self._policy.wait == Trigger.NOWAIT: return self._send() # synchronous queue = Queue() queue.durable = False queue.declare(self._policy.url) reply = queue.name if self._policy.exchange: exchange = Exchange(self._policy.exchange) exchange.bind(queue, self._policy.url) reply = '/'.join((self._policy.exchange, queue.name)) try: return self._send(reply=reply, queue=queue) finally: queue.purge(self._policy.url) queue.delete(self._policy.url)
def setup(self): """ Setup the broker model. """ if not self.managed: # not managed return url = self.plugin.url queue = Queue(self.queue) queue.auto_delete = self.expiration > 0 queue.expiration = self.expiration queue.declare(url) if self.exchange: exchange = Exchange(self.exchange) exchange.bind(queue, url)
def test_crud(self): print 'test CRUD' queue = Queue('test.13') queue.durable = False queue.declare(self.url) exchange = Exchange('test_crud_13.direct') exchange.declare(self.url) exchange.bind(queue, self.url) queue.delete(self.url) exchange.delete(self.url)
def test_crud(self): print('test CRUD') queue = Queue('test.13') queue.durable = False queue.declare(self.url) exchange = Exchange('test_crud_13.direct') exchange.declare(self.url) exchange.bind(queue, self.url) queue.delete(self.url) exchange.delete(self.url)
def test_crud(self): print "test CRUD" queue = Queue("test.13") queue.durable = False queue.declare(self.url) exchange = Exchange("test_crud_13.direct") exchange.declare(self.url) exchange.bind(queue, self.url) queue.delete(self.url) exchange.delete(self.url)
def test_custom_direct_exchange(self): print 'test custom (direct) exchange' address = Address('test_11.direct/test.11') exchange = Exchange(address.exchange, policy='direct') exchange.durable = False exchange.declare(self.url) queue = Queue(address.queue) queue.durable = False queue.declare(self.url) exchange.bind(queue, self.url) self.producer_reader(address)
def test_custom_topic_exchange(self): print 'test custom (topic) exchange' address = Address('test_12.topic/test.12') exchange = Exchange(address.exchange, policy='topic') exchange.durable = False exchange.declare(self.url) queue = Queue(address.queue) queue.durable = False queue.declare(self.url) exchange.bind(queue, self.url) self.producer_reader(address)
def test_custom_direct_exchange(self): print('test custom (direct) exchange') address = Address('test_11.direct/test.11') exchange = Exchange(address.exchange, policy='direct') exchange.durable = False exchange.declare(self.url) queue = Queue(address.queue) queue.durable = False queue.declare(self.url) exchange.bind(queue, self.url) self.producer_reader(address)
def test_custom_topic_exchange(self): print('test custom (topic) exchange') address = Address('test_12.topic/test.12') exchange = Exchange(address.exchange, policy='topic') exchange.durable = False exchange.declare(self.url) queue = Queue(address.queue) queue.durable = False queue.declare(self.url) exchange.bind(queue, self.url) self.producer_reader(address)