コード例 #1
0
ファイル: Router.php プロジェクト: rockxcn/messenger
 /**
  * Find queue name where to route message
  *
  * @param Oggetto_Messenger_Model_Message_Interface $message Message
  * @return string|null
  */
 public function findMessageQueue(Oggetto_Messenger_Model_Message_Interface $message)
 {
     foreach ($this->_map as $_map) {
         if ($message->matchesCriterion($_map['criterion'])) {
             return $_map['queue'];
         }
     }
 }
コード例 #2
0
ファイル: Dispatcher.php プロジェクト: rockxcn/messenger
 /**
  * Build message from event
  *
  * @param Oggetto_Messenger_Model_Event             $event   Event
  * @param Oggetto_Messenger_Model_Message_Interface $message Message
  *
  * @return Oggetto_Messenger_Model_Message_Interface
  */
 public function buildMessage(Oggetto_Messenger_Model_Event $event, Oggetto_Messenger_Model_Message_Interface $message)
 {
     $message->setMeta(array('_class' => 'event', 'name' => $event->getName()));
     $message->setData($event->getData());
     return $message;
 }
コード例 #3
0
ファイル: Rabbitmq.php プロジェクト: rockxcn/messenger
 /**
  * Send message to queue
  *
  * @param Oggetto_Messenger_Model_Message_Interface $message Message
  * @param string                                    $queue   Queue
  *
  * @return void
  */
 private function _sendMessage(Oggetto_Messenger_Model_Message_Interface $message, $queue)
 {
     $rabbitMessage = new AMQPMessage($message->toString(), array('delivery_mode' => 2));
     $this->_logger->info("Sending message to queue '{$queue}': {$rabbitMessage->body}");
     $transport = new Varien_Object();
     Mage::dispatchEvent('rabbitmq_publish_before', ['message' => $rabbitMessage, 'transport' => $transport]);
     $this->_getChannel()->basic_publish($rabbitMessage, '', $queue);
     Mage::dispatchEvent('rabbitmq_publish_after', ['message' => $rabbitMessage, 'transport' => $transport]);
 }
コード例 #4
0
ファイル: Receiver.php プロジェクト: rockxcn/messenger
 /**
  * Build event from message
  *
  * @param Oggetto_Messenger_Model_Message_Interface $message Message
  * @return Oggetto_Messenger_Model_Event
  */
 public function buildEvent(Oggetto_Messenger_Model_Message_Interface $message)
 {
     $meta = new Varien_Object((array) $message->getMeta());
     return Mage::getModel('messenger/event')->setName($meta->getName())->setData((array) $message->getData());
 }