/** * @param Queue $queue * @param string $message * @param \Magento\Sales\Api\Data\InvoiceInterface|\Magento\Sales\Api\Data\CreditmemoInterface $entity */ protected function resetQueueingForProcessing(Queue $queue, $message, $entity) { // Check retry attempts and determine if we need to fail processing // Add a comment to the order indicating what has been done if ($queue->getAttempts() >= $this->avaTaxConfig->getQueueMaxRetryAttempts()) { $message .= __(' The processing has failed due to reaching the maximum number of attempts to retry. ' . 'Any corrective measures will need to be initiated manually'); // fail processing later by setting queue status to pending $this->failQueueProcessing($queue, $message); // Add comment to order $this->addOrderComment($entity->getOrderId(), $message); } else { $message .= __(' The processing is set to automatically retry on the next processing attempt.'); // retry processing later by setting queue status to pending $queue->setMessage($message); $queue->setQueueStatus(Queue::QUEUE_STATUS_PENDING); $queue->save(); // Add comment to order $this->addOrderComment($entity->getOrderId(), $message); } }