/** * Helper: remove message sequence record(s) for the given * basic.{n}ack (RMQ Confirm key) */ private function removeConfirmSeqs(wire\Method $meth, $event) { if (!$this->callbackHandler) { trigger_error("Received publish confirmations with no channel event handler in place", E_USER_WARNING); return; } $dtag = $meth->getField('delivery-tag'); if ($meth->getField('multiple')) { foreach (array_keys($this->confirmSeqs) as $sk) { if ($sk <= $dtag) { $this->callbackHandler->{$event}($this->confirmSeqs[$sk]); unset($this->confirmSeqs[$sk]); } } } else { if (array_key_exists($dtag, $this->confirmSeqs)) { $this->callbackHandler->{$event}($this->confirmSeqs[$dtag]); unset($this->confirmSeqs[$dtag]); } } }
/** * Factory method creates wire\Method objects based on class name * and parameters. * * @arg string $class Amqp class * @arg array $_args Format: array (<Amqp method name>, * <Assoc method/class mixed field array>, * <Message content>) * @return A corresponding \amqphp\wire\Method */ function constructMethod($class, $_args) { $method = isset($_args[0]) ? $_args[0] : null; $args = isset($_args[1]) ? $_args[1] : array(); $content = isset($_args[2]) ? $_args[2] : null; $pl = $this->getProtocolLoader(); if (!($cls = $pl('ClassFactory', 'GetClassByName', array($class)))) { throw new \Exception("Invalid Amqp class or php method", 8691); } else { if (!($meth = $cls->getMethodByName($method))) { throw new \Exception("Invalid Amqp method", 5435); } } $m = new wire\Method($meth); foreach ($args as $k => $v) { $m->setField($k, $v); } $m->setContent($content); return $m; }