diff --git a/composer.json b/composer.json index f5555ae..d8c8e5c 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "psr/log": "^1.0 || ^2.0 || ^3.0", "setono/composite-compiler-pass": "^1.1", "setono/doctrine-orm-trait": "^1.1", - "setono/peak-wms-php-sdk": "^1.0@alpha", + "setono/peak-wms-php-sdk": "^1.1", "sylius/admin-bundle": "^1.0", "sylius/core": "^1.0", "sylius/core-bundle": "^1.0", diff --git a/src/Message/CommandHandler/ProcessUploadProductVariantRequestHandler.php b/src/Message/CommandHandler/ProcessUploadProductVariantRequestHandler.php index cba21f9..340a12b 100644 --- a/src/Message/CommandHandler/ProcessUploadProductVariantRequestHandler.php +++ b/src/Message/CommandHandler/ProcessUploadProductVariantRequestHandler.php @@ -8,10 +8,12 @@ use Setono\Doctrine\ORMTrait; use Setono\PeakWMS\Client\ClientInterface; use Setono\PeakWMS\DataTransferObject\Product\Product; +use Setono\PeakWMS\Exception\TooManyRequestsException; use Setono\SyliusPeakPlugin\DataMapper\Product\ProductDataMapperInterface; use Setono\SyliusPeakPlugin\Message\Command\ProcessUploadProductVariantRequest; use Setono\SyliusPeakPlugin\Model\UploadProductVariantRequestInterface; use Setono\SyliusPeakPlugin\Workflow\UploadProductVariantRequestWorkflow; +use Symfony\Component\Messenger\Exception\RecoverableMessageHandlingException; use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException; use Symfony\Component\Workflow\WorkflowInterface; @@ -63,6 +65,13 @@ public function __invoke(ProcessUploadProductVariantRequest $message): void } $this->uploadProductVariantRequestWorkflow->apply($uploadProductVariantRequest, UploadProductVariantRequestWorkflow::TRANSITION_UPLOAD); + } catch (TooManyRequestsException $e) { + $this->uploadProductVariantRequestWorkflow->apply($uploadProductVariantRequest, UploadProductVariantRequestWorkflow::TRANSITION_RESET); + + throw new RecoverableMessageHandlingException( + message: sprintf('Failed to process upload product variant request with id %d', $message->uploadProductVariantRequest), + previous: $e, + ); } catch (\Throwable $e) { $uploadProductVariantRequest->setError($e->getMessage());