Browse Source

Should not pass Queue.as_dict as message properties...

Ask Solem 12 years ago
parent
commit
45f8724466
2 changed files with 13 additions and 6 deletions
  1. 10 2
      celery/app/amqp.py
  2. 3 4
      celery/app/routes.py

+ 10 - 2
celery/app/amqp.py

@@ -182,8 +182,16 @@ class TaskProducer(Producer):
             queue=None, now=None, retries=0, chord=None, callbacks=None,
             errbacks=None, mandatory=None, priority=None, immediate=None,
             routing_key=None, serializer=None, delivery_mode=None,
-            compression=None, **kwargs):
+            compression=None, declare=None, **kwargs):
         """Send task message."""
+
+        declare = declare or []
+        if queue is not None:
+            if isinstance(queue, basestring):
+                queue = self.queues[queue]
+            exchange = exchange or queue.exchange.name
+            routing_key = routing_key or queue.routing_key
+
         # merge default and custom policy
         retry = self.retry if retry is None else retry
         _rp = (dict(self.retry_policy, **retry_policy) if retry_policy
@@ -225,7 +233,7 @@ class TaskProducer(Producer):
              serializer=serializer or self.serializer,
              compression=compression or self.compression,
              retry=retry, retry_policy=_rp, delivery_mode=delivery_mode,
-             priority=priority, declare=[self.queues[queue]] if queue else [],
+             priority=priority, declare=declare)
              **kwargs)
 
         signals.task_sent.send(sender=task_name, **body)

+ 3 - 4
celery/app/routes.py

@@ -60,7 +60,7 @@ class Router(object):
 
         if queue:  # expand config from configured queue.
             try:
-                dest = self.queues[queue].as_dict()
+                _Q = self.queues[queue]  # noqa
             except KeyError:
                 if not self.create_missing:
                     raise QueueNotFound(
@@ -68,10 +68,9 @@ class Router(object):
                 for key in 'exchange', 'routing_key':
                     if route.get(key) is None:
                         route[key] = queue
-                dest = self.app.amqp.queues.add(queue, **route).as_dict()
+                self.app.amqp.queues.add(queue, **route)
             # needs to be declared by publisher
-            dest['queue'] = queue
-            return lpmerge(dest, route)
+            route['queue'] = queue
         return route
 
     def lookup_route(self, task, args=None, kwargs=None):