Browse Source

agregue routing key para task logger

Luciano Andrade 7 years ago
parent
commit
2094aebf7b
1 changed files with 7 additions and 3 deletions
  1. 7 3
      Services/ProducerService.php

+ 7 - 3
Services/ProducerService.php

@@ -53,7 +53,11 @@ class ProducerService
             $actionRepository = $this->getEntityManager()->getRepository('WorkflowBundle:Action');
             $actions = $actionRepository->findAllByEventAndObjectClass($eventName, $entityClass);
             foreach ($actions as $action) {
-                $this->publishMessage($action, $entity);
+                $routing_key = "";
+                if(getenv("AMQP_KEY") !== false){
+                        $routing_key = getenv("AMQP_KEY");
+                }
+                $this->publishMessage($action, $entity, $routing_key);
             }
         }
     }
@@ -82,7 +86,7 @@ class ProducerService
      * @param Action $action
      * @param Entity $entity
      */
-    public function publishMessage(Action $action, $entity)
+    public function publishMessage(Action $action, $entity, $routing_key = "")
     {
         $entityClass = get_class($entity);
         $actionName = $action->getName();
@@ -93,7 +97,7 @@ class ProducerService
             'entityClass' => $entityClass,
             'entityId' => $entityId,
         );
-        $this->producer->publish(serialize($msg));
+	$this->producer->publish(serialize($msg), $routing_key);
                 
         $msg = serialize($msg);