|
1 |
| -/* |
2 |
| - * Licensed to the Apache Software Foundation (ASF) under one or more |
3 |
| - * contributor license agreements. See the NOTICE file distributed with |
4 |
| - * this work for additional information regarding copyright ownership. |
5 |
| - * The ASF licenses this file to You under the Apache License, Version 2.0 |
6 |
| - * (the "License"); you may not use this file except in compliance with |
7 |
| - * the License. You may obtain a copy of the License at |
8 |
| - * |
9 |
| - * http://www.apache.org/licenses/LICENSE-2.0 |
10 |
| - * |
11 |
| - * Unless required by applicable law or agreed to in writing, software |
12 |
| - * distributed under the License is distributed on an "AS IS" BASIS, |
13 |
| - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 |
| - * See the License for the specific language governing permissions and |
15 |
| - * limitations under the License. |
16 |
| - */ |
17 |
| - |
18 |
| -#ifndef __SENDCALLBACK_H__ |
19 |
| -#define __SENDCALLBACK_H__ |
20 |
| - |
21 |
| -#include "MQClientException.h" |
22 |
| -#include "PullResult.h" |
23 |
| -#include "RocketMQClient.h" |
24 |
| -#include "SendResult.h" |
25 |
| - |
26 |
| -namespace rocketmq { |
27 |
| -//<!*************************************************************************** |
28 |
| -struct AsyncCallback {}; |
29 |
| -//<!*************************************************************************** |
30 |
| -typedef enum sendCallbackType { |
31 |
| - noAutoDeleteSendCallback = 0, |
32 |
| - autoDeleteSendCallback = 1 |
33 |
| -} sendCallbackType; |
34 |
| - |
35 |
| -class ROCKETMQCLIENT_API SendCallback : public AsyncCallback { |
36 |
| - public: |
37 |
| - virtual ~SendCallback() {} |
38 |
| - virtual void onSuccess(SendResult& sendResult) = 0; |
39 |
| - virtual void onException(MQException& e) = 0; |
40 |
| - virtual sendCallbackType getSendCallbackType() { |
41 |
| - return noAutoDeleteSendCallback; |
42 |
| - } |
43 |
| -}; |
44 |
| - |
45 |
| -//async SendCallback will be deleted automatically by rocketmq cpp after invoke callback interface |
46 |
| -class ROCKETMQCLIENT_API AutoDeleteSendCallBack : public SendCallback { |
47 |
| - public: |
48 |
| - virtual ~AutoDeleteSendCallBack() {} |
49 |
| - virtual void onSuccess(SendResult& sendResult) = 0; |
50 |
| - virtual void onException(MQException& e) = 0; |
51 |
| - virtual sendCallbackType getSendCallbackType() { |
52 |
| - return autoDeleteSendCallback; |
53 |
| - } |
54 |
| -}; |
55 |
| - |
56 |
| -//<!************************************************************************ |
57 |
| -class ROCKETMQCLIENT_API PullCallback : public AsyncCallback { |
58 |
| - public: |
59 |
| - virtual ~PullCallback() {} |
60 |
| - virtual void onSuccess(MQMessageQueue& mq, PullResult& result, |
61 |
| - bool bProducePullRequest) = 0; |
62 |
| - virtual void onException(MQException& e) = 0; |
63 |
| -}; |
64 |
| -//<!*************************************************************************** |
65 |
| -} //<!end namespace; |
66 |
| -#endif |
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +#ifndef __SENDCALLBACK_H__ |
| 19 | +#define __SENDCALLBACK_H__ |
| 20 | + |
| 21 | +#include "MQClientException.h" |
| 22 | +#include "PullResult.h" |
| 23 | +#include "RocketMQClient.h" |
| 24 | +#include "SendResult.h" |
| 25 | + |
| 26 | +namespace rocketmq { |
| 27 | +//<!*************************************************************************** |
| 28 | +struct AsyncCallback {}; |
| 29 | +//<!*************************************************************************** |
| 30 | +typedef enum sendCallbackType { noAutoDeleteSendCallback = 0, autoDeleteSendCallback = 1 } sendCallbackType; |
| 31 | + |
| 32 | +class ROCKETMQCLIENT_API SendCallback : public AsyncCallback { |
| 33 | + public: |
| 34 | + virtual ~SendCallback() {} |
| 35 | + virtual void onSuccess(SendResult &sendResult) = 0; |
| 36 | + virtual void onException(MQException &e) = 0; |
| 37 | + virtual sendCallbackType getSendCallbackType() { return noAutoDeleteSendCallback; } |
| 38 | +}; |
| 39 | + |
| 40 | +// async SendCallback will be deleted automatically by rocketmq cpp after invoke callback interface |
| 41 | +class ROCKETMQCLIENT_API AutoDeleteSendCallBack : public SendCallback { |
| 42 | + public: |
| 43 | + virtual ~AutoDeleteSendCallBack() {} |
| 44 | + virtual void onSuccess(SendResult &sendResult) = 0; |
| 45 | + virtual void onException(MQException &e) = 0; |
| 46 | + virtual sendCallbackType getSendCallbackType() { return autoDeleteSendCallback; } |
| 47 | +}; |
| 48 | + |
| 49 | +//<!************************************************************************ |
| 50 | +class ROCKETMQCLIENT_API PullCallback : public AsyncCallback { |
| 51 | + public: |
| 52 | + virtual ~PullCallback() {} |
| 53 | + virtual void onSuccess(MQMessageQueue &mq, PullResult &result, bool bProducePullRequest) = 0; |
| 54 | + virtual void onException(MQException &e) = 0; |
| 55 | +}; |
| 56 | + |
| 57 | +//<!*************************************************************************** |
| 58 | +} // namespace rocketmq |
| 59 | + |
| 60 | +#endif // __SENDCALLBACK_H__ |
0 commit comments