Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion AligentAsyncEventsBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@

class AligentAsyncEventsBundle extends Bundle
{

}
4 changes: 2 additions & 2 deletions Async/AbstractRetryableProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
use Aligent\AsyncEventsBundle\Entity\FailedJob;
use Aligent\AsyncEventsBundle\Exception\RetryableException;
use Doctrine\ORM\ORMException;
use Oro\Component\MessageQueue\Client\Config;
use Oro\Component\MessageQueue\Consumption\MessageProcessorInterface;
use Oro\Component\MessageQueue\Transport\MessageInterface;
use Oro\Component\MessageQueue\Transport\SessionInterface;
use Oro\Component\MessageQueue\Util\JSON;
use Psr\Log\LoggerInterface;
use Oro\Component\MessageQueue\Client\Config;
use Symfony\Bridge\Doctrine\ManagerRegistry;

abstract class AbstractRetryableProcessor implements MessageProcessorInterface, RetryableProcessorInterface
Expand Down Expand Up @@ -113,5 +113,5 @@ protected function handleFailure(MessageInterface $message, RetryableException $
* @return string
* @throws RetryableException
*/
abstract public function execute(MessageInterface $message);
abstract public function execute(MessageInterface $message): string;
}
9 changes: 1 addition & 8 deletions Async/RetryableProcessorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,9 @@

namespace Aligent\AsyncEventsBundle\Async;

use Aligent\AsyncEventsBundle\Exception\RetryableException;
use Oro\Component\MessageQueue\Transport\MessageInterface;

interface RetryableProcessorInterface
{

/**
* @param MessageInterface $message
* @throws RetryableException
* @return string
*/
public function execute(MessageInterface $message);
public function execute(MessageInterface $message): string;
}
22 changes: 22 additions & 0 deletions Async/Topic/WebhookEntityCreateTopic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Aligent\AsyncEventsBundle\Async\Topic;

class WebhookEntityCreateTopic extends \Oro\Component\MessageQueue\Topic\AbstractTopic
{
public const NAME = 'aligent.webhook.entity.create';

public static function getName(): string
{
return self::NAME;
}
public static function getDescription(): string
{
// TODO: Implement getDescription() method.
return '';
}
public function configureMessageBody(\Symfony\Component\OptionsResolver\OptionsResolver $resolver): void
{
// TODO: Implement configureMessageBody() method.
}
}
22 changes: 22 additions & 0 deletions Async/Topic/WebhookEntityCustomTopic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Aligent\AsyncEventsBundle\Async\Topic;

class WebhookEntityCustomTopic extends \Oro\Component\MessageQueue\Topic\AbstractTopic
{
public const NAME = 'aligent.webhook.entity.custom';

public static function getName(): string
{
return self::NAME;
}
public static function getDescription(): string
{
// TODO: Implement getDescription() method.
return '';
}
public function configureMessageBody(\Symfony\Component\OptionsResolver\OptionsResolver $resolver): void
{
// TODO: Implement configureMessageBody() method.
}
}
22 changes: 22 additions & 0 deletions Async/Topic/WebhookEntityDeleteTopic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Aligent\AsyncEventsBundle\Async\Topic;

class WebhookEntityDeleteTopic extends \Oro\Component\MessageQueue\Topic\AbstractTopic
{
public const NAME = 'aligent.webhook.entity.delete';

public static function getName(): string
{
return self::NAME;
}
public static function getDescription(): string
{
// TODO: Implement getDescription() method.
return '';
}
public function configureMessageBody(\Symfony\Component\OptionsResolver\OptionsResolver $resolver): void
{
// TODO: Implement configureMessageBody() method.
}
}
22 changes: 22 additions & 0 deletions Async/Topic/WebhookEntityUpdateTopic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Aligent\AsyncEventsBundle\Async\Topic;

class WebhookEntityUpdateTopic extends \Oro\Component\MessageQueue\Topic\AbstractTopic
{
public const NAME = 'aligent.webhook.entity.update';

public static function getName(): string
{
return self::NAME;
}
public static function getDescription(): string
{
// TODO: Implement getDescription() method.
return '';
}
public function configureMessageBody(\Symfony\Component\OptionsResolver\OptionsResolver $resolver): void
{
// TODO: Implement configureMessageBody() method.
}
}
28 changes: 0 additions & 28 deletions Async/Topics.php

This file was deleted.

27 changes: 16 additions & 11 deletions Async/WebhookEntityProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

namespace Aligent\AsyncEventsBundle\Async;

use Aligent\AsyncEventsBundle\Exception\RetryableException;
use Aligent\AsyncEventsBundle\Async\Topic\WebhookEntityCreateTopic;
use Aligent\AsyncEventsBundle\Async\Topic\WebhookEntityCustomTopic;
use Aligent\AsyncEventsBundle\Async\Topic\WebhookEntityDeleteTopic;
use Aligent\AsyncEventsBundle\Async\Topic\WebhookEntityUpdateTopic;
use Aligent\AsyncEventsBundle\Entity\WebhookTransport as WebhookTransportEntity;
use Aligent\AsyncEventsBundle\Exception\RetryableException;
use Aligent\AsyncEventsBundle\Integration\WebhookTransport;
use Aligent\AsyncEventsBundle\Provider\WebhookConfigProvider;
use GuzzleHttp\Exception\GuzzleException;
use Oro\Bundle\EntityExtendBundle\EntityReflectionClass;
use Oro\Bundle\ImportExportBundle\Serializer\SerializerInterface;
use Oro\Bundle\IntegrationBundle\Entity\Channel;
use Oro\Component\MessageQueue\Client\Config;
Expand All @@ -26,10 +31,10 @@
class WebhookEntityProcessor extends AbstractRetryableProcessor implements TopicSubscriberInterface
{
const EVENT_MAP = [
Topics::WEBHOOK_ENTITY_UPDATE => WebhookConfigProvider::UPDATE,
Topics::WEBHOOK_ENTITY_DELETE => WebhookConfigProvider::DELETE,
Topics::WEBHOOK_ENTITY_CREATE => WebhookConfigProvider::CREATE,
Topics::WEBHOOK_ENTITY_CUSTOM => WebhookConfigProvider::CUSTOM,
WebhookEntityUpdateTopic::NAME => WebhookConfigProvider::UPDATE,
WebhookEntityDeleteTopic::NAME => WebhookConfigProvider::DELETE,
WebhookEntityCreateTopic::NAME => WebhookConfigProvider::CREATE,
WebhookEntityCustomTopic::NAME => WebhookConfigProvider::CUSTOM,
];

protected WebhookTransport $transport;
Expand Down Expand Up @@ -109,7 +114,7 @@ public function execute(MessageInterface $message): string
$this->logger->error(
$message,
[

'channelId' => $channel->getId(),
'channel' => $channel->getName(),
'topic' => $topic,
Expand All @@ -128,10 +133,10 @@ public function execute(MessageInterface $message): string
public static function getSubscribedTopics(): array
{
return [
Topics::WEBHOOK_ENTITY_CREATE,
Topics::WEBHOOK_ENTITY_DELETE,
Topics::WEBHOOK_ENTITY_UPDATE,
Topics::WEBHOOK_ENTITY_CUSTOM,
WebhookEntityCreateTopic::getName(),
WebhookEntityDeleteTopic::getName(),
WebhookEntityUpdateTopic::getName(),
WebhookEntityCustomTopic::getName(),
];
}

Expand All @@ -155,7 +160,7 @@ protected function buildPayload(string $event, array $data): array
}
}

$reflClass = new \ReflectionClass($data['class']);
$reflClass = new EntityReflectionClass($data['class']);

return [
'type' => $reflClass->getShortName(),
Expand Down
33 changes: 13 additions & 20 deletions Controller/FailedJobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@

use Aligent\AsyncEventsBundle\Entity\FailedJob;
use Doctrine\Persistence\ManagerRegistry;
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor;
use Oro\Bundle\SecurityBundle\Attribute\Acl;
use Oro\Bundle\SecurityBundle\Attribute\AclAncestor;
use Oro\Component\MessageQueue\Client\MessageProducerInterface;
use Oro\Component\MessageQueue\Transport\Exception\Exception;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Oro\Bundle\SecurityBundle\Annotation\Acl;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;

class FailedJobController extends AbstractController
{

protected MessageProducerInterface $messageProducer;
protected ManagerRegistry $doctrine;

Expand All @@ -39,15 +38,9 @@ public function __construct(MessageProducerInterface $messageProducer, ManagerRe
$this->doctrine = $managerRegistry;
}

/**
* @Route(name="aligent_failed_jobs_index")
* @Acl(
* id="failed_jobs",
* type="action",
* label="Retryable Jobs"
* )
* @Template()
*/
#[Route(name: 'aligent_failed_jobs_index')]
#[Acl(id: 'failed_jobs', type: 'action', label: 'RetryableJobs')]
#[Template]
public function indexAction()
{
return [];
Expand All @@ -56,12 +49,12 @@ public function indexAction()
/**
* View Failed Job
*
* @Route("/view/{id}", name="aligent_failed_jobs_view")
* @AclAncestor("failed_jobs")
* @Template()
* @param FailedJob $job
* @return array
*/
#[Route(path: '/view/{id}', name: 'aligent_failed_jobs_view')]
#[AclAncestor('failed_jobs')]
#[Template]
public function viewAction(FailedJob $job)
{
return [
Expand All @@ -72,11 +65,11 @@ public function viewAction(FailedJob $job)
/**
* Delete Failed Job
*
* @Route("/remove/{id}", name="aligent_failed_jobs_delete")
* @AclAncestor("failed_jobs")
* @param FailedJob $job
* @return JsonResponse
*/
#[Route(path: '/remove/{id}', name: 'aligent_failed_jobs_delete')]
#[AclAncestor('failed_jobs')]
public function deleteAction(FailedJob $job)
{
try {
Expand All @@ -93,11 +86,11 @@ public function deleteAction(FailedJob $job)
/**
* Retry Failed jobs
*
* @Route("/retry/{id}", name="aligent_failed_jobs_retry")
* @AclAncestor("failed_jobs")
* @param FailedJob $job
* @return JsonResponse
*/
#[Route(path: '/retry/{id}', name: 'aligent_failed_jobs_retry')]
#[AclAncestor('failed_jobs')]
public function retryAction(FailedJob $job)
{
try {
Expand Down
4 changes: 2 additions & 2 deletions Datagrid/Extension/MassAction/MassRetryActionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

namespace Aligent\AsyncEventsBundle\Datagrid\Extension\MassAction;

use Aligent\AsyncEventsBundle\Entity\FailedJob;
use Oro\Bundle\DataGridBundle\Extension\MassAction\MassActionHandlerArgs;
use Oro\Bundle\DataGridBundle\Extension\MassAction\MassActionHandlerInterface;
use Oro\Bundle\DataGridBundle\Extension\MassAction\MassActionResponse;
use Oro\Bundle\DataGridBundle\Extension\MassAction\MassActionResponseInterface;
use Oro\Component\MessageQueue\Client\MessageProducerInterface;

class MassRetryActionHandler implements MassActionHandlerInterface
Expand Down Expand Up @@ -43,7 +43,7 @@ public function __construct(MessageProducerInterface $messageProducer)
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*/
public function handle(MassActionHandlerArgs $args)
public function handle(MassActionHandlerArgs $args): MassActionResponseInterface
{
$results = $args->getResults();
$em = $results->getSource()->getEntityManager();
Expand Down
3 changes: 1 addition & 2 deletions DependencyInjection/AligentAsyncEventsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class AligentAsyncEventsExtension extends Extension
{

/**
* Loads a specific configuration.
*
Expand Down
Loading