ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleMysqlMq\Model;
|
||||
|
||||
class DataObject extends \Magento\Framework\Api\AbstractExtensibleObject
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->_get('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
return $this->setData('name', $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getEntityId()
|
||||
{
|
||||
return $this->_get('entity_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $entityId
|
||||
* @return $this
|
||||
*/
|
||||
public function setEntityId($entityId)
|
||||
{
|
||||
return $this->setData('entity_id', $entityId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOutputPath()
|
||||
{
|
||||
return $this->_get('outputPath');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return $this
|
||||
*/
|
||||
public function setOutputPath($path)
|
||||
{
|
||||
return $this->setData('outputPath', $path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleMysqlMq\Model;
|
||||
|
||||
class DataObjectRepository
|
||||
{
|
||||
/**
|
||||
* @param DataObject $dataObject
|
||||
* @param string $requiredParam
|
||||
* @param int|null $optionalParam
|
||||
* @return null
|
||||
*/
|
||||
public function delayedOperation(
|
||||
\Magento\TestModuleMysqlMq\Model\DataObject $dataObject,
|
||||
$requiredParam,
|
||||
$optionalParam = null
|
||||
) {
|
||||
$output = "Processed '{$dataObject->getEntityId()}'; "
|
||||
. "Required param '{$requiredParam}'; Optional param '{$optionalParam}'\n";
|
||||
file_put_contents($dataObject->getOutputPath(), $output);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\TestModuleMysqlMq\Model;
|
||||
|
||||
use LogicException;
|
||||
use Magento\Framework\MessageQueue\ConnectionLostException;
|
||||
|
||||
/**
|
||||
* Test message processor is used by \Magento\MysqlMq\Model\PublisherConsumerTest
|
||||
*/
|
||||
class Processor
|
||||
{
|
||||
/**
|
||||
* @param DataObject $message
|
||||
*/
|
||||
public function processMessage($message)
|
||||
{
|
||||
file_put_contents(
|
||||
$message->getOutputPath(),
|
||||
"Processed {$message->getEntityId()}" . PHP_EOL,
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $message
|
||||
*/
|
||||
public function processObjectCreated($message)
|
||||
{
|
||||
file_put_contents(
|
||||
$message->getOutputPath(),
|
||||
"Processed object created {$message->getEntityId()}" . PHP_EOL,
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $message
|
||||
*/
|
||||
public function processCustomObjectCreated($message)
|
||||
{
|
||||
file_put_contents(
|
||||
$message->getOutputPath(),
|
||||
"Processed custom object created {$message->getEntityId()}" . PHP_EOL,
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $message
|
||||
*/
|
||||
public function processObjectUpdated($message)
|
||||
{
|
||||
file_put_contents(
|
||||
$message->getOutputPath(),
|
||||
"Processed object updated {$message->getEntityId()}" . PHP_EOL,
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $message
|
||||
*/
|
||||
public function processMessageWithException($message)
|
||||
{
|
||||
file_put_contents($message->getOutputPath(), "Exception processing {$message->getEntityId()}");
|
||||
throw new LogicException(
|
||||
"Exception during message processing happened. Entity: {{$message->getEntityId()}}"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ConnectionLostException
|
||||
*/
|
||||
public function processMessageWithConnectionException()
|
||||
{
|
||||
throw new ConnectionLostException(
|
||||
"Connection exception during message processing happened."
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user