def __init__(self, channel, name, no_ack=None, queue_opts=None, exchange_opts=None, serializer=None, compression=None, **kwargs): queue = name queue_opts = dict(self.queue_opts, **queue_opts or {}) exchange_opts = dict(self.exchange_opts, **exchange_opts or {}) if no_ack is None: no_ack = self.no_ack if not isinstance(queue, entity.Queue): exchange = entity.Exchange(name, "direct", **exchange_opts) queue = entity.Queue(name, exchange, name, **queue_opts) else: name = queue.name exchange = queue.exchange producer = messaging.Producer(channel, exchange, serializer=serializer, routing_key=name, compression=compression) consumer = messaging.Consumer(channel, queue) super(SimpleQueue, self).__init__(channel, producer, consumer, no_ack, **kwargs)
def __init__(self, connection, queue=None, exchange=None, routing_key=None, exchange_type=None, durable=None, exclusive=None, auto_delete=None, **kwargs): self.connection = connection self.backend = connection.channel() if durable is not None: self.durable = durable if exclusive is not None: self.exclusive = exclusive if auto_delete is not None: self.auto_delete = auto_delete self.queue = queue or self.queue self.exchange = exchange or self.exchange self.exchange_type = exchange_type or self.exchange_type self.routing_key = routing_key or self.routing_key exchange = entity.Exchange(self.exchange, type=self.exchange_type, routing_key=self.routing_key, auto_delete=self.auto_delete, durable=self.durable) queue = entity.Queue(self.queue, exchange=exchange, routing_key=self.routing_key, durable=self.durable, exclusive=self.exclusive, auto_delete=self.auto_delete) super(Consumer, self).__init__(self.backend, queue, **kwargs)
def __init__(self, channel, name, no_ack=None, queue_opts=None, queue_args=None, exchange_opts=None, serializer=None, compression=None, **kwargs): queue = name queue_opts = dict(self.queue_opts, **queue_opts or {}) queue_args = dict(self.queue_args, **queue_args or {}) exchange_opts = dict(self.exchange_opts, **exchange_opts or {}) if no_ack is None: no_ack = self.no_ack if not isinstance(queue, entity.Queue): exchange = entity.Exchange(name, **exchange_opts) queue = entity.Queue(name, exchange, name, queue_arguments=queue_args, **queue_opts) routing_key = name else: exchange = queue.exchange routing_key = queue.routing_key consumer = messaging.Consumer(channel, queue) producer = messaging.Producer(channel, exchange, serializer=serializer, routing_key=routing_key, compression=compression) super(AmqpBuffer, self).__init__(channel, producer, consumer, no_ack, **kwargs)
def __init__(self, connection, queue_name): super(DT, self).__init__() self.queue_name = queue_name self.connection = connection self.exchange = Exchange(name="event1", type="direct") self._queue = entity.Queue(queue_name, exchange=self.exchange, routing_key=queue_name) self.queue = SimpleQueue(self.connection, self._queue)
def entry_to_queue(queue, **options): binding_key = options.get("binding_key") or options.get("routing_key") e_durable = options.get("exchange_durable") if e_durable is None: e_durable = options.get("durable") e_auto_delete = options.get("exchange_auto_delete") if e_auto_delete is None: e_auto_delete = options.get("auto_delete") q_durable = options.get("queue_durable") if q_durable is None: q_durable = options.get("durable") q_auto_delete = options.get("queue_auto_delete") if q_auto_delete is None: q_auto_delete = options.get("auto_delete") e_arguments = options.get("exchange_arguments") q_arguments = options.get("queue_arguments") b_arguments = options.get("binding_arguments") exchange = entity.Exchange(options.get("exchange"), type=options.get("exchange_type"), delivery_mode=options.get("delivery_mode"), routing_key=options.get("routing_key"), durable=e_durable, auto_delete=e_auto_delete, arguments=e_arguments) return entity.Queue(queue, exchange=exchange, routing_key=binding_key, durable=q_durable, exclusive=options.get("exclusive"), auto_delete=q_auto_delete, no_ack=options.get("no_ack"), queue_arguments=q_arguments, binding_arguments=b_arguments)