瀏覽代碼

agregue routing key para task logger

Luciano Andrade 7 年之前
父節點
當前提交
2094aebf7b
共有 1 個文件被更改,包括 7 次插入3 次删除
  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);