ltsecurityinc安防产品在线商城代码
This commit is contained in:
Executable
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2023 JR or its affiliates. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace JR\Customer\Model;
|
||||
|
||||
use Aws\Exception\AwsException;
|
||||
use Aws\Sqs\SqsClient;
|
||||
|
||||
class SqsAdapter
|
||||
{
|
||||
/**
|
||||
* @var SqsClient
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
// $this->client = new SqsClient([
|
||||
// 'version' => 'latest',
|
||||
// 'region' => $config->getDefaultRegion(),
|
||||
// 'credentials' => [
|
||||
// 'key' => $config->getAccessKey(),
|
||||
// 'secret' => $config->getSecret()
|
||||
// ],
|
||||
// ]);
|
||||
|
||||
$this->client = new SqsClient([
|
||||
'version' => 'latest',
|
||||
'region' => 'us-west-1',
|
||||
'credentials' => [
|
||||
'key' => 'AKIAI255FGJWZPKYHE2Q',
|
||||
'secret' => 'BqWVBucfi6omK4ejpoVJSk2NmN6xch+bO8hwliYa'
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return \Aws\Result
|
||||
* @throws AwsException
|
||||
*/
|
||||
public function getQueues()
|
||||
{
|
||||
return $this->client->listQueues();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
* @return string
|
||||
*/
|
||||
public function getQueueUrl($args)
|
||||
{
|
||||
$result = $this->client->getQueueUrl($args);
|
||||
return $result->get('QueueUrl');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $queueUrl
|
||||
* @param string $body
|
||||
* @param array $attributes
|
||||
* @param int $delay
|
||||
* @return \Aws\Result
|
||||
* @throws AwsException
|
||||
*/
|
||||
public function sendMessage($queueUrl, $body, $attributes = [], $delay = 0)
|
||||
{
|
||||
$params = [
|
||||
'DelaySeconds' => $delay,
|
||||
'MessageAttributes' => $attributes,
|
||||
'MessageBody' => $body,
|
||||
'QueueUrl' => $queueUrl
|
||||
];
|
||||
return $this->client->sendMessage($params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user