MessageIdGenerator.php 800 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\MessageQueue;
  7. /**
  8. * Generate unique id for queue message.
  9. */
  10. class MessageIdGenerator implements MessageIdGeneratorInterface
  11. {
  12. /**
  13. * @var \Magento\Framework\Encryption\EncryptorInterface
  14. */
  15. private $encryptor;
  16. /**
  17. * Initialize dependencies.
  18. *
  19. * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
  20. */
  21. public function __construct(
  22. \Magento\Framework\Encryption\EncryptorInterface $encryptor
  23. ) {
  24. $this->encryptor = $encryptor;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function generate($topicName)
  30. {
  31. return $this->encryptor->hash(uniqid($topicName));
  32. }
  33. }