2👍
Producer.exchange
must be an Exchange
. By default it’s Exchange("")
, somehow you must have set it to a string.
0👍
Where ever you be passing value to ‘exchange‘ param it has to be an Exchange
object.
Your code has to be:
exchange = Exchange(name='inbound') # the minimal declaration
connection = establish_connection()
producer = Producer(channel=connection,
exchange=exchange,
routing_key="apisubmit")
producer.publish(body=pl,headers={"api_access_key": "xxxx", "client_id": 4, "object_type": "location", "action": "c"})
For full list of Exchange param – docs.
I encountered the same error at queue declaration i.e.
queue = Queue(name=queue_name, exchange='host_tasks', routing_key=binding_key)
bound_queue = queue(channel) # only once bound, we can call declare(), purge(), delete() on exchange
So declared an Exchange, such thah
exchange = Exchange('host_tasks', 'direct', durable=True)
queue = Queue(name=queue_name, exchange=exchange, routing_key=binding_key)
bound_queue = queue(channel)
Don’t forget to import Exchange
- [Answered ]-How can I order a Django query against a custom list of values?
- [Answered ]-Django: Importing a view from another app
- [Answered ]-How to to override database settings in a Django TestCase
- [Answered ]-Using "google-like" colon-search operator with Haystack
- [Answered ]-Django Query or SQL
Source:stackexchange.com