public function batchPublish(array $messages)
 {
     $records = aray();
     foreach ($messages as $message) {
         $records[] = array('Data' => $message['msgBody'], 'PartitionKey' => $message['routingKey']);
     }
     $result = $this->client->putRecords(array_merge(array('StreamName' => $this->streamName, 'Records' => $records), $this->getClientParams()));
 }
 /**
  * {@inheritdoc}
  */
 public function handleBatch(array $records)
 {
     $kinesisParameters = $this->getFormatter()->formatBatch($records);
     $kinesisParameters['StreamName'] = $this->streamName;
     try {
         /** @noinspection PhpUndefinedMethodInspection */
         $this->kinesisClient->putRecords($kinesisParameters);
     } catch (\Exception $ex) {
         // As above, we intentionally allow logs to drop when Kinesis fails for any reason
     }
     return false === $this->bubble;
 }
Exemple #3
0
 /**
  * Send multiple events to Event bus
  *
  * Will submit all events in .2 seconds
  *
  * @param $event
  * @param $key
  * @param $object_name
  * @param $data
  * @return bool|\Guzzle\Service\Resource\Model
  */
 public function sendMultiple($event, $key, $object_name, $data)
 {
     if ($this->client == null) {
         return false;
     }
     $records = [];
     foreach ($data as $record) {
         $event_data = ['id' => $this->id, 'event' => $event, 'reference_id' => strtolower($object_name) . '_' . $record[$object_name][$key], 'payload' => $record];
         $records[] = ['Data' => SafeJson::encode($event_data), 'PartitionKey' => $record[$object_name][$key]];
     }
     $time_start = microtime(true);
     $result = $this->client->putRecords(['Records' => $records, 'StreamName' => $this->streamName]);
     $time_end = microtime(true);
     $this->time_taken = number_format($time_end - $time_start, 2);
     return $result;
 }