protected function onJobScheduledForExecution($job_message) { $delivery_info = $job_message->delivery_info; $channel = $delivery_info['channel']; $delivery_tag = $delivery_info['delivery_tag']; $job_state = JsonToolkit::parse($job_message->body); $job = $this->job_service->createJob($job_state); try { $job->run(); } catch (Exception $error) { throw $error; if ($job->getStrategy()->canRetry()) { $this->job_service->retry($job, $delivery_info['exchange'] . '.waiting'); } else { $this->job_service->fail($job, ['error_message' => $error->getMessage(), 'error_trace' => $error->getTraceAsString()]); } } // acknowledge the message to remove it from the event queue. // an 'ack' is effectively the same as a 'nack'. $channel->basic_ack($delivery_tag); }
protected function getTypeMappings(MigrationTarget $migration_target) { $mappings = []; $paths = (array) $this->getTypeMappingPaths($migration_target); foreach ($paths as $type_name => $mapping_file) { if (!is_readable($mapping_file)) { throw new RuntimeError(sprintf('Unable to read type-mapping at: %s', $mapping_file)); } $mappings[$type_name] = JsonToolkit::parse(file_get_contents($mapping_file)); } return $mappings; }
protected function tryToReadPayload() { $serialized_payload = fgets($this->file_pointer); if (!$serialized_payload) { return new BulkStreamError(BulkStreamError::INVALID_FORMAT, "Reached EOF, but was expecting payload for current metadata of the given bulk-operation."); } try { return JsonToolkit::parse($serialized_payload); } catch (ParseError $parse_error) { return new BulkStreamError(BulkStreamError::INVALID_PAYLOAD, "Failed to parse payload for the given bulk-operation. Reason: " . $parse_error->getMessage()); } }