AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
SQSQueue.h
1
5#pragma once
6
7#include <aws/queues/Queue.h>
8#include <aws/sqs/model/Message.h>
9#include <aws/queues/Queues_EXPORTS.h>
10#include <memory>
11#include <aws/core/client/AsyncCallerContext.h>
12#include <aws/sqs/SQSClient.h>
13
14namespace Aws
15{
16 namespace SQS
17 {
18 namespace Model
19 {
20 class DeleteMessageRequest;
21 class SendMessageRequest;
22 }
23 }
24
25 namespace Queues
26 {
27 namespace Sqs
28 {
32 class AWS_QUEUES_API SQSQueue : public Queue<Aws::SQS::Model::Message>
33 {
34
35 typedef std::function<void(const SQSQueue*, const Aws::SQS::Model::GetQueueAttributesOutcome&)> QueueAttributeSuccessEventHandler;
36 typedef std::function<void(const SQSQueue*, const Aws::SQS::Model::GetQueueAttributesRequest&)> QueueAttributeFailedEventHandler;
37 typedef std::function<void(const SQSQueue*, const Aws::SQS::Model::GetQueueAttributesRequest&)> QueueArnFailedEventHandler;
38 typedef std::function<void(const SQSQueue*, const Aws::String&)> QueueArnSuccessEventHandler;
39
40 public:
41
45 inline void SetQueueArnSuccessEventHandler(const QueueArnSuccessEventHandler& messageHandler) { m_queueArnSuccessHandler = messageHandler; }
46 inline void SetQueueArnSuccessEventHandler(QueueArnSuccessEventHandler&& messageHandler) { m_queueArnSuccessHandler = messageHandler; }
47
51 inline void SetQueueArnFailedEventHandler(const QueueArnFailedEventHandler& messageHandler) { m_queueArnFailedHandler = messageHandler; }
52 inline void SetQueueArnFailedEventHandler(QueueArnFailedEventHandler&& messageHandler) { m_queueArnFailedHandler = messageHandler; }
53
57 inline void SetQueueAttributeSuccessEventHandler(const QueueAttributeSuccessEventHandler& messageHandler) { m_queueAttributeSuccessHandler = messageHandler; }
58 inline void SetQueueAttributeSuccessEventHandler(QueueAttributeSuccessEventHandler&& messageHandler) { m_queueAttributeSuccessHandler = messageHandler; }
59
63 inline void SetQueueAttributeFailedEventHandler(const QueueAttributeFailedEventHandler& messageHandler) { m_queueAttributeFailedHandler = messageHandler; }
64 inline void SetQueueAttributeFailedEventHandler(QueueAttributeFailedEventHandler&& messageHandler) { m_queueAttributeFailedHandler = messageHandler; }
65
66 inline const QueueArnSuccessEventHandler& GetQueueArnSuccessEventHandler() const { return m_queueArnSuccessHandler; }
67 inline const QueueArnFailedEventHandler& GetQueueArnFailedEventHandler() const { return m_queueArnFailedHandler; }
68
69 inline const QueueAttributeSuccessEventHandler& GetQueueAttributeSuccessEventHandler() const { return m_queueAttributeSuccessHandler; }
70 inline const QueueAttributeFailedEventHandler& GetQueueAttributeFailedEventHandler() const { return m_queueAttributeFailedHandler; }
71
72
77 SQSQueue(const std::shared_ptr<SQS::SQSClient>& client, const char* queueName, unsigned visibilityTimeout, unsigned pollingFrequencyMs = 10000);
78
82 Aws::SQS::Model::Message Top() const override;
83
87 void Delete(const Aws::SQS::Model::Message&) override;
88
92 void Push(const Aws::SQS::Model::Message&) override;
93
97 void RequestArn();
98
103
104 inline bool IsInitialized() const { return !m_queueUrl.empty(); }
105 inline const Aws::String& GetQueueUrl() const { return m_queueUrl; }
106
107 private:
108 std::shared_ptr<SQS::SQSClient> m_client;
109 Aws::String m_queueUrl;
110 Aws::String m_queueName;
111 unsigned m_visibilityTimeout;
112
113 void OnMessageDeletedOutcomeReceived(const SQS::SQSClient*, const SQS::Model::DeleteMessageRequest&,
114 const SQS::Model::DeleteMessageOutcome& deleteMessageOutcome, const std::shared_ptr<const Client::AsyncCallerContext>&);
115
116 void OnMessageSentOutcomeReceived(const SQS::SQSClient*, const SQS::Model::SendMessageRequest&,
117 const SQS::Model::SendMessageOutcome& deleteMessageOutcome, const std::shared_ptr<const Client::AsyncCallerContext>&);
118
119 void OnGetQueueAttributesOutcomeReceived(const SQS::SQSClient*, const SQS::Model::GetQueueAttributesRequest&,
120 const SQS::Model::GetQueueAttributesOutcome& deleteMessageOutcome, const std::shared_ptr<const Client::AsyncCallerContext>&);
121
122 QueueArnSuccessEventHandler m_queueArnSuccessHandler;
123 QueueArnFailedEventHandler m_queueArnFailedHandler;
124 QueueAttributeSuccessEventHandler m_queueAttributeSuccessHandler;
125 QueueAttributeFailedEventHandler m_queueAttributeFailedHandler;
126
127 };
128 }
129 }
130}
bool IsInitialized() const
Definition SQSQueue.h:104
void SetQueueAttributeFailedEventHandler(const QueueAttributeFailedEventHandler &messageHandler)
Definition SQSQueue.h:63
void SetQueueArnFailedEventHandler(QueueArnFailedEventHandler &&messageHandler)
Definition SQSQueue.h:52
void SetQueueArnSuccessEventHandler(const QueueArnSuccessEventHandler &messageHandler)
Definition SQSQueue.h:45
void SetQueueAttributeSuccessEventHandler(QueueAttributeSuccessEventHandler &&messageHandler)
Definition SQSQueue.h:58
void SetQueueArnSuccessEventHandler(QueueArnSuccessEventHandler &&messageHandler)
Definition SQSQueue.h:46
SQSQueue(const std::shared_ptr< SQS::SQSClient > &client, const char *queueName, unsigned visibilityTimeout, unsigned pollingFrequencyMs=10000)
const QueueAttributeSuccessEventHandler & GetQueueAttributeSuccessEventHandler() const
Definition SQSQueue.h:69
void SetQueueAttributeFailedEventHandler(QueueAttributeFailedEventHandler &&messageHandler)
Definition SQSQueue.h:64
void Delete(const Aws::SQS::Model::Message &) override
void SetQueueAttributeSuccessEventHandler(const QueueAttributeSuccessEventHandler &messageHandler)
Definition SQSQueue.h:57
const QueueArnFailedEventHandler & GetQueueArnFailedEventHandler() const
Definition SQSQueue.h:67
const QueueArnSuccessEventHandler & GetQueueArnSuccessEventHandler() const
Definition SQSQueue.h:66
void SetQueueArnFailedEventHandler(const QueueArnFailedEventHandler &messageHandler)
Definition SQSQueue.h:51
const QueueAttributeFailedEventHandler & GetQueueAttributeFailedEventHandler() const
Definition SQSQueue.h:70
Aws::SQS::Model::Message Top() const override
const Aws::String & GetQueueUrl() const
Definition SQSQueue.h:105
void Push(const Aws::SQS::Model::Message &) override
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String