public function send($consumerGroup, $topics) { // Add header (ApiKey, ApiVersion, CorrelationId, ClientId) $data = $this->buildHeader(); // Add ConsumerGroup $data .= Packer::packStringSignedInt16($consumerGroup); // Add Topic count $data .= Packer::packSignedInt32(count($topics)); // Add Topics foreach ($topics as $topic => $partitions) { // Add Topic $data .= Packer::packStringSignedInt16($topic); // Add Partition count $data .= Packer::packSignedInt32(count($partitions)); // Add Partitions foreach ($partitions as $partition) { // Add Partition $data .= Packer::packSignedInt32($partition); } } // Concat data length (32 bits) and data $data = Packer::packStringSignedInt32($data); // Send data return $this->client->write($data); }
public function send($groupId, $sessionTimeout, $memberId, $protocolType, $groupProtocols) { // Add header (ApiKey, ApiVersion, CorrelationId, ClientId) $data = $this->buildHeader(); // Add GroupId $data .= Packer::packStringSignedInt16($groupId); // Add SessionTimeout $data .= Packer::packSignedInt32($sessionTimeout); // Add MemberId $data .= Packer::packStringSignedInt16($memberId); // Add ProtocolType $data .= Packer::packStringSignedInt16($protocolType); // Add GroupProtocol count $data .= Packer::packSignedInt32(count($groupProtocols)); // Add GroupProtocols foreach ($groupProtocols as $protocolName => $protocolMetadata) { // Add ProtocolName $data .= Packer::packStringSignedInt16($protocolName); // Add ProtocolMetadata $data .= Packer::packStringSignedInt32($protocolMetadata); } // Concat data length (32 bits) and data $data = Packer::packStringSignedInt32($data); // Sent data return $this->client->write($data); }
public function send($replicaId = -1, $topics) { // Add header (ApiKey, ApiVersion, CorrelationId, ClientId) $data = $this->buildHeader(); // Add ReplicaId $data .= Packer::packSignedInt32($replicaId); // Add Topic count $data .= Packer::packSignedInt32(count($topics)); // Add Topics foreach ($topics as $topic => $partitions) { // Add Topic $data .= Packer::packStringSignedInt16($topic); // Add Partition count $data .= Packer::packSignedInt32(count($partitions)); // Add Partitions foreach ($partitions as $partition => $partitionParams) { // Add Partition $data .= Packer::packSignedInt32($partition); // Add Time $data .= Packer::packSignedInt64($partitionParams['Time']); // Add MaxNumberOfOffsets $data .= Packer::packSignedInt32($partitionParams['MaxNumberOfOffsets']); } } // Concat data length (32 bits) and data $data = Packer::packStringSignedInt32($data); // Send data return $this->client->write($data); }
public function send($replicaId = -1, $maxWaitTime = 100, $minBytes = 1024, $topics) { // Add header (ApiKey, ApiVersion, CorrelationId, ClientId) $data = $this->buildHeader(); // Add ReplicaId $data .= Packer::packSignedInt32($replicaId); // Add MaxWaitTime $data .= Packer::packSignedInt32($maxWaitTime); // Add MinBytes $data .= Packer::packSignedInt32($minBytes); // Add Topic count $data .= Packer::packSignedInt32(count($topics)); // Add Topics foreach ($topics as $topic => $partitions) { // Add Topic $data .= Packer::packStringSignedInt16($topic); // Add Partition count $data .= Packer::packSignedInt32(count($partitions)); // Add Partitions foreach ($partitions as $partition => $partitionParams) { // Add Partition $data .= Packer::packSignedInt32($partition); // Add Partition offset $data .= Packer::packSignedInt64($partitionParams['offset']); // Add PartitionMaxBytes $data .= Packer::packSignedInt32($partitionParams['max_bytes']); } } // Concat data length (32 bits) and data $data = Packer::packStringSignedInt32($data); // Send data return $this->client->write($data); }
public function send() { // Add header (ApiKey, ApiVersion, CorrelationId, ClientId) $data = $this->buildHeader(); // Concat data length (32 bits) and data $data = Packer::packStringSignedInt32($data); // Send data return $this->client->write($data); }
public function send($requiredAcks, $timeout, $topics) { // Add header (ApiKey, ApiVersion, CorrelationId, ClientId) $data = $this->buildHeader(); // Add RequiredAcks $data .= Packer::packSignedInt16($requiredAcks); // Add Timeout $data .= Packer::packSignedInt32($timeout); // Add Topic count $data .= Packer::packSignedInt32(count($topics)); // Add Topics foreach ($topics as $topic => $partitions) { // Add Topic $data .= Packer::packStringSignedInt16($topic); // Add Partition count $data .= Packer::packSignedInt32(count($partitions)); // Add Partitions foreach ($partitions as $partition => $messages) { $data .= Packer::packSignedInt32($partition); $packedMessageSet = ''; foreach ($messages as $message) { if (!is_array($message)) { $offset = 0; // Producer does not know message offset, so we can fill with any value (we choose 0) $magicByte = 0; // Used to ensure backwards compatibility. Currently set to 0; $attributes = 0; $key = null; } else { $offset = array_key_exists('Offset', $message) ? $message['Offset'] : 0; $magicByte = array_key_exists('MagicByte', $message) ? $message['MagicByte'] : 0; $attributes = array_key_exists('Attributes', $message) ? $message['Attributes'] : 0; $attributes = 0; // TODO: handle compression $key = array_key_exists('Key', $message) ? $message['Key'] : null; } $packedMessage = Packer::packSignedInt8($magicByte); $packedMessage .= Packer::packSignedInt8($attributes); $packedMessage .= Packer::packStringSignedInt32($key); $packedMessage .= Packer::packStringSignedInt32($message); $packedMessage = Packer::packSignedInt32(crc32($packedMessage)) . $packedMessage; $packedMessageSet .= Packer::packSignedInt64($offset) . Packer::packStringSignedInt32($packedMessage); } // Add MessageSet $data .= Packer::packStringSignedInt32($packedMessageSet); } } // Concat data length (32 bits) and data $data = Packer::packStringSignedInt32($data); // Send data return $this->client->write($data); }
public function send($groupId, $generationId, $memberId) { // Add header (ApiKey, ApiVersion, CorrelationId, ClientId) $data = $this->buildHeader(); // Add GroupId $data .= Packer::packStringSignedInt16($groupId); // Add GenerationId $data .= Packer::packSignedInt32($generationId); // Add MemberId $data .= Packer::packStringSignedInt16($memberId); // Concat data length (32 bits) and data $data = Packer::packStringSignedInt32($data); // Send data return $this->client->write($data); }
public function send($groupIds) { // Add header (ApiKey, ApiVersion, CorrelationId, ClientId) $data = $this->buildHeader(); // Add GroupIds $data .= Packer::packSignedInt32(count($groupIds)); foreach ($groupIds as $groupId) { // Add GroupId $data .= Packer::packStringSignedInt16($groupId); } // Concat data length (32 bits) and data $data = Packer::packStringSignedInt32($data); // Send data return $this->client->write($data); }
public function send($topics) { // Add header (ApiKey, ApiVersion, CorrelationId, ClientId) $data = $this->buildHeader(); // Add Topic count $data .= Packer::packSignedInt32(count($topics)); // Add Topics foreach ($topics as $topic) { // Add Topic $data .= Packer::packStringSignedInt16($topic); } // Concat data length (32 bits) and data $data = Packer::packStringSignedInt32($data); // Send the message return $this->client->write($data); }