Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adds batch publish methods

  • Loading branch information...
commit d969e657f49a3999446c671cfe4930398d597c64 1 parent 97ca6bd
@videlalvaro authored
Showing with 28 additions and 1 deletion.
  1. +28 −1 PhpAmqpLib/Channel/AMQPChannel.php
View
29 PhpAmqpLib/Channel/AMQPChannel.php
@@ -569,6 +569,33 @@ public function basic_publish($msg, $exchange="", $routing_key="",
$mandatory=false, $immediate=false,
$ticket=null)
{
+ $data = $this->prepare_basic_publish($msg, $exchange, $routing_key,
+ $mandatory, $immediate, $ticket);
+ $this->connection->write($data);
+ }
+
+ protected $to_publish = array();
+
+ public function batch_basic_publish($msg, $exchange="", $routing_key="",
+ $mandatory=false, $immediate=false,
+ $ticket=null)
+ {
+ $this->to_publish[] = $this->prepare_basic_publish($msg, $exchange, $routing_key,
+ $mandatory, $immediate, $ticket);
+ }
+
+ public function publish_batch()
+ {
+ if (!empty($this->to_publish)) {
+ $this->connection->write(implode('', $this->to_publish));
+ }
+ $this->to_publish = array();
+ }
+
+ protected function prepare_basic_publish($msg, $exchange="", $routing_key="",
+ $mandatory=false, $immediate=false,
+ $ticket=null)
+ {
$ticket = $this->getTicket($ticket);
$args = $this->frameBuilder->basicPublish(
$exchange, $routing_key, $mandatory,
@@ -580,7 +607,7 @@ public function basic_publish($msg, $exchange="", $routing_key="",
strlen($msg->body),
$msg->serialize_properties(),
$msg->body);
- $this->connection->write($data);
+ return $data;
}
Please sign in to comment.
Something went wrong with that request. Please try again.