Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 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)
Beispiel #6
0
 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)
Beispiel #7
0
 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)
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
 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)
Beispiel #11
0
 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)