Esempio n. 1
0
 def downstream_exchange_declare(self, name, type_, upstream=None):
     if not upstream:
         upstream = self._default_exchange
     with Connection(self._url) as connection:
         channel = connection.default_channel
         exchange = Exchange(name, type_).bind(channel)
         exchange.declare()
         upstream.bind(channel).declare()
         exchange.bind_to(upstream, routing_key='#')
Esempio n. 2
0
    print('  properties:\n%s' % (pretty(message.properties), ))
    print('  delivery_info:\n%s' % (pretty(message.delivery_info), ))
    message.ack()

#: Create a connection and a channel.
#: If hostname, userid, password and virtual_host is not specified
#: the values below are the default, but listed here so it can
#: be easily changed.
with Connection('pyamqp://*****:*****@localhost:5672//') as connection:
    # The configuration of the message flow is as follows:
    #   gateway_kombu_exchange -> internal_kombu_exchange -> kombu_demo queue
    gateway_exchange = Exchange('gateway_kombu_demo')(connection)
    exchange = Exchange('internal_kombu_demo')(connection)
    gateway_exchange.declare()
    exchange.declare()
    exchange.bind_to(gateway_exchange, routing_key='kombu_demo')

    queue = Queue('kombu_demo', exchange, routing_key='kombu_demo')

    #: Create consumer using our callback and queue.
    #: Second argument can also be a list to consume from
    #: any number of queues.
    with Consumer(connection, queue, callbacks=[handle_message]):

        #: This waits for a single event.  Note that this event may not
        #: be a message, or a message that is to be delivered to the consumers
        #: channel, but any event received on the connection.
        recv = eventloop(connection)
        while True:
            recv.next()