-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APPS-7128: MessageBroker for Message Bus v 2.0 implementation (#10302)
MessageBroker for Message Bus v 2.0 implementation
- Loading branch information
1 parent
628fa33
commit 39bca2e
Showing
23 changed files
with
649 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Spryker/Zed/MessageBroker/Business/Exception/MissingMessageSenderException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\MessageBroker\Business\Exception; | ||
|
||
use Exception; | ||
|
||
class MissingMessageSenderException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/Spryker/Zed/MessageBroker/Business/MessageChannelProvider/MessageChannelProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\MessageBroker\Business\MessageChannelProvider; | ||
|
||
use Spryker\Zed\MessageBroker\Business\Config\ConfigFormatterInterface; | ||
use Spryker\Zed\MessageBroker\Business\Exception\CouldNotMapMessageToChannelNameException; | ||
use Spryker\Zed\MessageBroker\MessageBrokerConfig; | ||
use Symfony\Component\Messenger\Envelope; | ||
|
||
class MessageChannelProvider implements MessageChannelProviderInterface | ||
{ | ||
/** | ||
* @var \Spryker\Zed\MessageBroker\MessageBrokerConfig | ||
*/ | ||
protected MessageBrokerConfig $config; | ||
|
||
/** | ||
* @var \Spryker\Zed\MessageBroker\Business\Config\ConfigFormatterInterface | ||
*/ | ||
protected ConfigFormatterInterface $configFormatter; | ||
|
||
/** | ||
* @param \Spryker\Zed\MessageBroker\MessageBrokerConfig $config | ||
* @param \Spryker\Zed\MessageBroker\Business\Config\ConfigFormatterInterface $configFormatter | ||
*/ | ||
public function __construct(MessageBrokerConfig $config, ConfigFormatterInterface $configFormatter) | ||
{ | ||
$this->config = $config; | ||
$this->configFormatter = $configFormatter; | ||
} | ||
|
||
/** | ||
* @param \Symfony\Component\Messenger\Envelope $envelope | ||
* | ||
* @throws \Spryker\Zed\MessageBroker\Business\Exception\CouldNotMapMessageToChannelNameException | ||
* | ||
* @return string | ||
*/ | ||
public function getChannelForMessage(Envelope $envelope): string | ||
{ | ||
$messageToChannelMap = $this->config->getMessageToChannelMap(); | ||
|
||
if (is_string($messageToChannelMap)) { | ||
$messageToChannelMap = $this->configFormatter->format($messageToChannelMap); | ||
} | ||
|
||
$messageClass = get_class($envelope->getMessage()); | ||
|
||
if (isset($messageToChannelMap[$messageClass])) { | ||
return $messageToChannelMap[$messageClass]; | ||
} | ||
|
||
throw new CouldNotMapMessageToChannelNameException(sprintf( | ||
'Could not map "%s" message class to a channel', | ||
$messageClass, | ||
)); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ker/Zed/MessageBroker/Business/MessageChannelProvider/MessageChannelProviderInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Zed\MessageBroker\Business\MessageChannelProvider; | ||
|
||
use Symfony\Component\Messenger\Envelope; | ||
|
||
interface MessageChannelProviderInterface | ||
{ | ||
/** | ||
* @param \Symfony\Component\Messenger\Envelope $envelope | ||
* | ||
* @throws \Spryker\Zed\MessageBroker\Business\Exception\CouldNotMapMessageToChannelNameException | ||
* | ||
* @return string | ||
*/ | ||
public function getChannelForMessage(Envelope $envelope): string; | ||
} |
Oops, something went wrong.