ons 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +7 -0
  5. data/.yardopts +3 -0
  6. data/Gemfile +4 -0
  7. data/README-zh_CN.md +80 -0
  8. data/README.md +36 -0
  9. data/Rakefile +10 -0
  10. data/bin/console +14 -0
  11. data/bin/rake +9 -0
  12. data/bin/setup +8 -0
  13. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/Action.h +12 -0
  14. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/ConsumeContext.h +15 -0
  15. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/LocalTransactionChecker.h +16 -0
  16. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/LocalTransactionExecuter.h +16 -0
  17. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/Message.h +96 -0
  18. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/MessageListener.h +20 -0
  19. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/ONSChannel.h +17 -0
  20. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/ONSClient.h +28 -0
  21. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/ONSClientException.h +27 -0
  22. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/ONSFactory.h +73 -0
  23. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/Producer.h +29 -0
  24. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/PushConsumer.h +22 -0
  25. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/SendResultONS.h +22 -0
  26. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/TransactionProducer.h +22 -0
  27. data/ext/ons/aliyun-mq-cpp-sdk/include/ons/TransactionStatus.h +15 -0
  28. data/ext/ons/aliyun-mq-cpp-sdk/lib/libonsclient4cpp.so +0 -0
  29. data/ext/ons/consumer.cpp +68 -0
  30. data/ext/ons/consumer.hpp +33 -0
  31. data/ext/ons/extconf.rb +44 -0
  32. data/ext/ons/listener.cpp +19 -0
  33. data/ext/ons/listener.hpp +25 -0
  34. data/ext/ons/lmfao.cpp +251 -0
  35. data/ext/ons/lmfao.hpp +101 -0
  36. data/ext/ons/ons.cpp +19 -0
  37. data/ext/ons/ons.hpp +7 -0
  38. data/ext/ons/producer.cpp +74 -0
  39. data/ext/ons/producer.hpp +30 -0
  40. data/lib/ons/consumer.rb +71 -0
  41. data/lib/ons/lmfao.rb +18 -0
  42. data/lib/ons/producer.rb +80 -0
  43. data/lib/ons/version.rb +3 -0
  44. data/lib/ons.rb +36 -0
  45. data/ons.gemspec +42 -0
  46. data/samples/consumer.rb +32 -0
  47. data/samples/producer.rb +35 -0
  48. metadata +218 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 80474fb3032832392ef7844f0eb062d11203fcd8
4
+ data.tar.gz: f4014c329ff734765715541a016631b1c00d73b5
5
+ SHA512:
6
+ metadata.gz: 2201e16dd77b6e767a706b1fc40e2fc644c3c0a31575f480d123aee995fd9d890aae3a43dd61f95cde34454fe13c1d287ef74a27dd5d8feace32b827f51982fb
7
+ data.tar.gz: d5970d7a6b0742bb2ade1ae031e6f9c903ad831f3d48c4e769c39acdb18ed9893977fbda76e8f1763d3438e8f17e0dbbc9991f12e692a54467feb3068a9b39df
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ /ext/ons/mkmf.log
12
+ /ext/ons/Makefile
13
+ /ext/ons/*.o
14
+ /ext/ons/*.so
15
+ /lib/ons/ons.so
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ require: rubocop-rspec
2
+
3
+ Metrics/LineLength:
4
+ Max: 160
5
+
6
+ RSpec/ExampleLength:
7
+ Max: 16
data/.yardopts ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ README.md
3
+ README-zh_CN.md
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ons.gemspec
4
+ gemspec
data/README-zh_CN.md ADDED
@@ -0,0 +1,80 @@
1
+ # Ons
2
+
3
+ 阿里云 ONS 消息队列服务 Ruby SDK(非官方版本)
4
+
5
+ ## 项目依赖
6
+
7
+ * Linux/Unix 系统
8
+ * Ruby 2.1.5 或以上版本
9
+ * Boost C++ 程序库
10
+
11
+ ## 安装步骤
12
+
13
+ ### 安装 Ruby 程序
14
+
15
+ ```sh
16
+ $ rvm install 2.1.5
17
+ ```
18
+
19
+ ### 安装 Boost C++ 程序库
20
+
21
+ ```sh
22
+ $ apt-get install libboost-all-dev
23
+ ```
24
+
25
+ ### 安装 ons
26
+
27
+ ```sh
28
+ $ git clone https://github.com/souche/aliyun-ons-ruby-sdk.git
29
+ $ cd ons
30
+ $ ./bin/setup
31
+ $ ./bin/rake install
32
+ ```
33
+
34
+ ## 使用方式
35
+
36
+ ### 环境准备
37
+
38
+ * 安装 ons rubygems。
39
+ * 代码里涉及到的 TOPIC、PRODUCER_ID、CONSUMER_ID,需要在 MQ 控制台上创建。 Message Tag 可以完全由应用自定义,具体创建过程可参考 [申请MQ资源](https://help.aliyun.com/document_detail/29536.html)。
40
+ * 使用 MQ 服务的应用程序需要部署在阿里云 ECS 上。
41
+
42
+ 部分资料来自 [消息队列 > TCP 接入(专业) > C/C++ SDK 环境准备](https://help.aliyun.com/document_detail/29555.html)
43
+
44
+ ### 生产者
45
+
46
+ ```ruby
47
+ producer = Ons::Producer.new('<ONS_ACCESS_KEY>', '<ONS_SECRET_KEY>', '<ONS_PRODUCER_ID>')
48
+
49
+ # 资源准备
50
+ producer.start
51
+
52
+ # 在 topic <ONS_TOPIC> 下发送消息
53
+ producer.send_message('<ONS_TOPIC>', 'tag', 'Hello, World!')
54
+
55
+ # 必须在程序退出前调用 shutdown 方法释放相关资源,否则可能出现栈错误
56
+ producer.shutdown
57
+ ```
58
+
59
+ 更多用法,请参考 {file:samples/producer.rb} 及 API 文档
60
+
61
+ ### 消费者
62
+
63
+ ```ruby
64
+ consumer = Ons::Consumer.new('<ONS_ACCESS_KEY>', '<ONS_SECRET_KEY>', '<ONS_CONSUMER_ID>')
65
+
66
+ # 订阅 topic <ONS_TOPIC> 下的所有消息
67
+ # 注意,当消息达到时,会调用下述函数,此函数会被调度到单独线程中执行
68
+ consumer.subscribe('<ONS_TOPIC>', '*') { |message| p message }
69
+
70
+ # 资源准备
71
+ consumer.start
72
+
73
+ # 等待消息到达
74
+ sleep 32
75
+
76
+ # 必须在程序退出前调用 shutdown 方法释放相关资源,否则可能出现栈错误
77
+ consumer.shutdown
78
+ ```
79
+
80
+ 更多用法,请参考 {file:samples/consumer.rb} 及 API 文档
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Ons
2
+
3
+ unoffical aliyun ONS sdk (ruby version)
4
+
5
+ ## Requirements
6
+
7
+ * Linux/Unix
8
+ * Ruby 2.1.5 or later
9
+ * Boost C++ library
10
+
11
+ ## Installation
12
+
13
+ ### install Ruby
14
+
15
+ ```sh
16
+ $ rvm install 2.1.5
17
+ ```
18
+
19
+ ### install Boost C++ library
20
+
21
+ ```sh
22
+ $ apt-get install libboost-all-dev
23
+ ```
24
+
25
+ ### install ons
26
+
27
+ ```sh
28
+ $ git clone https://github.com/souche/aliyun-ons-ruby-sdk.git
29
+ $ cd ons
30
+ $ ./bin/setup
31
+ $ ./bin/rake install
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Please take a look at {file:samples/producer.rb} and {file:samples/consumer.rb}
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/extensiontask'
3
+ require 'rspec/core/rake_task'
4
+
5
+ Rake::ExtensionTask.new(:ons) do |ext|
6
+ ext.lib_dir = './lib/ons'
7
+ end
8
+
9
+ RSpec::Core::RakeTask.new spec: %w(clobber compile)
10
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'ons'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/rake ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pathname'
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
5
+
6
+ require 'rubygems'
7
+ require 'bundler/setup'
8
+
9
+ load Gem.bin_path('rake', 'rake')
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ #ifndef __ACTION_H__
2
+ #define __ACTION_H__
3
+
4
+ //consuming result
5
+ enum Action{
6
+ //consume success, application could continue to consume next message
7
+ CommitMessage,
8
+ //consume fail, server will deliver this message later, application could continue to consume next message
9
+ ReconsumeLater
10
+ };
11
+ #endif
12
+
@@ -0,0 +1,15 @@
1
+ #ifndef __CONSUMECONTEXT_H__
2
+ #define __CONSUMECONTEXT_H__
3
+
4
+ namespace ons{
5
+
6
+ class ONSCLIENT_API ConsumeContext{
7
+ public:
8
+ ConsumeContext(){}
9
+ virtual ~ConsumeContext(){}
10
+
11
+ };
12
+
13
+ }
14
+ #endif
15
+
@@ -0,0 +1,16 @@
1
+ #ifndef __LOCALTRANSACTIONCHECKER_H__
2
+ #define __LOCALTRANSACTIONCHECKER_H__
3
+
4
+ #include "Message.h"
5
+ #include "TransactionStatus.h"
6
+
7
+ namespace ons{
8
+ class LocalTransactionChecker {
9
+ public:
10
+ virtual TransactionStatus check(Message& msg) =0;
11
+ virtual ~LocalTransactionChecker() {}
12
+ };
13
+ }
14
+
15
+ #endif
16
+
@@ -0,0 +1,16 @@
1
+ #ifndef __LOCALTRANSACTIONEXECUTER_H__
2
+ #define __LOCALTRANSACTIONEXECUTER_H__
3
+
4
+ #include "Message.h"
5
+ #include "TransactionStatus.h"
6
+
7
+ namespace ons{
8
+ class LocalTransactionExecuter{
9
+ public:
10
+ virtual TransactionStatus execute(Message& msg) =0;
11
+ virtual ~LocalTransactionExecuter(){}
12
+ };
13
+ }
14
+
15
+ #endif
16
+
@@ -0,0 +1,96 @@
1
+ #ifndef __MESSAGE_H__
2
+ #define __MESSAGE_H__
3
+
4
+ #include <map>
5
+ #include <vector>
6
+ #include <sstream>
7
+ #include "ONSClient.h"
8
+ namespace ons {
9
+
10
+ class ONSCLIENT_API SystemPropKey
11
+ {
12
+ public:
13
+ SystemPropKey(){}
14
+ ~SystemPropKey(){}
15
+ static CONSTSTRING TAG;
16
+ static CONSTSTRING KEY;
17
+ static CONSTSTRING MSGID;
18
+ static CONSTSTRING RECONSUMETIMES;
19
+ static CONSTSTRING STARTDELIVERTIME;
20
+ };
21
+
22
+ //<!***************************************************************************
23
+ class ONSCLIENT_API Message
24
+ {
25
+ public:
26
+ Message();
27
+ Message(CONSTSTRING topic, CONSTSTRING tags, CONSTSTRING body);
28
+ Message(CONSTSTRING topic, CONSTSTRING tags, CONSTSTRING keys, CONSTSTRING body);
29
+
30
+ virtual ~Message();
31
+
32
+ Message(const Message& other);
33
+ Message& operator=(const Message& other);
34
+
35
+ //userProperties was used to save user specific parameters which doesn't belong to SystemPropKey
36
+ void putUserProperties(CONSTSTRING key, CONSTSTRING value);
37
+ CONSTSTRING getUserProperties(CONSTSTRING key) const;
38
+ void setUserProperties(std::map<std::string, std::string>& userProperty);
39
+ std::map<std::string, std::string> getUserProperties() const;
40
+
41
+ //systemProperties only save parameters defined in SystemPropKey, please do not add other parameters into systemProperties, else it was not saved.
42
+ void putSystemProperties(CONSTSTRING key,CONSTSTRING value);
43
+ CONSTSTRING getSystemProperties(CONSTSTRING key) const;
44
+ void setSystemProperties(std::map<std::string, std::string>& systemProperty);
45
+ std::map<std::string, std::string> getSystemProperties() const;
46
+
47
+ CONSTSTRING getTopic()const;
48
+ void setTopic(CONSTSTRING topic);
49
+
50
+ CONSTSTRING getTag() const;
51
+ void setTag(CONSTSTRING tags);
52
+
53
+ CONSTSTRING getKey() const;
54
+ void setKey(CONSTSTRING keys);
55
+
56
+ CONSTSTRING getMsgID() const;
57
+ void setMsgID(CONSTSTRING msgId);
58
+
59
+ const long long getStartDeliverTime() const;
60
+ void setStartDeliverTime(long long level);
61
+
62
+ CONSTSTRING getBody()const;
63
+ void setBody(CONSTSTRING msgbody);
64
+
65
+ const int getReconsumeTimes() const;
66
+ void setReconsumeTimes(int reconsumeTimes);
67
+
68
+ long long getStoreTimestamp() const;
69
+ void setStoreTimestamp(long long storeTimestamp);
70
+
71
+ const std::string toString() const;
72
+
73
+ const std::string toSystemString() const;
74
+
75
+ const std::string toUserString() const;
76
+
77
+ protected:
78
+ void Init(const std::string& topic,
79
+ const std::string& tags,
80
+ const std::string& keys,
81
+ const std::string& body);
82
+
83
+
84
+ private:
85
+ std::string topic;
86
+ std::string body;
87
+ long long m_storeTimestamp;
88
+ std::map<std::string, std::string> systemProperties;
89
+ std::map<std::string, std::string> userProperties;
90
+ };
91
+ //<!***************************************************************************
92
+
93
+
94
+ }//<!end namespace;
95
+ #endif
96
+
@@ -0,0 +1,20 @@
1
+ #ifndef __MESSAGELISTENER_H__
2
+ #define __MESSAGELISTENER_H__
3
+
4
+ #include "Action.h"
5
+ #include "Message.h"
6
+ #include "ConsumeContext.h"
7
+
8
+ namespace ons{
9
+
10
+ class ONSCLIENT_API MessageListener {
11
+ public:
12
+ MessageListener(){}
13
+ virtual ~MessageListener(){}
14
+
15
+ //interface of consuming message, should be realized by application
16
+ virtual Action consume(Message& message, ConsumeContext& context) = 0;
17
+ };
18
+
19
+ }
20
+ #endif
@@ -0,0 +1,17 @@
1
+ #ifndef __ONSCHANNEL_H__
2
+ #define __ONSCHANNEL_H__
3
+
4
+ namespace ons
5
+ {
6
+
7
+ enum ONSChannel
8
+ {
9
+ CLOUD,
10
+ ALIYUN,
11
+ ALL
12
+ };
13
+
14
+ }
15
+
16
+
17
+ #endif
@@ -0,0 +1,28 @@
1
+ /********************************************************************
2
+ author: ×ÔÐÞ jianlin.yjl@alibaba-cn.com
3
+ *********************************************************************/
4
+ #ifndef __ONSCLIENT_H__
5
+ #define __ONSCLIENT_H__
6
+
7
+ #include <string>
8
+
9
+ #ifdef WIN32
10
+ typedef const char* CONSTSTRING;
11
+ typedef char* STRING;
12
+ #else
13
+ typedef const std::string CONSTSTRING;
14
+ typedef std::string STRING;
15
+ #endif
16
+
17
+
18
+ #ifdef WIN32
19
+ #ifdef ONSCLIENT_EXPORTS
20
+ #define ONSCLIENT_API __declspec(dllexport)
21
+ #else
22
+ #define ONSCLIENT_API __declspec(dllimport)
23
+ #endif
24
+ #else
25
+ #define ONSCLIENT_API
26
+ #endif
27
+
28
+ #endif
@@ -0,0 +1,27 @@
1
+ #ifndef __ONSCLIENTEXCEPTION_H__
2
+ #define __ONSCLIENTEXCEPTION_H__
3
+
4
+ #include <exception>
5
+ #include "ONSClient.h"
6
+
7
+ namespace ons{
8
+
9
+ class ONSCLIENT_API ONSClientException: public std::exception
10
+ {
11
+ public:
12
+ ONSClientException() throw();
13
+ virtual ~ONSClientException() throw();
14
+ ONSClientException(std::string msg, int error) throw();
15
+ const char* GetMsg() const throw();
16
+ const char* what() const throw();
17
+ int GetError() const throw();
18
+
19
+ private:
20
+ std::string m_msg;
21
+ int m_error;
22
+ };
23
+
24
+ }
25
+
26
+
27
+ #endif
@@ -0,0 +1,73 @@
1
+ #ifndef __ONSFACTORY_H_
2
+ #define __ONSFACTORY_H_
3
+
4
+ #include "Producer.h"
5
+ #include "TransactionProducer.h"
6
+ #include "PushConsumer.h"
7
+ #include "ONSChannel.h"
8
+ #include "LocalTransactionChecker.h"
9
+
10
+ namespace ons {
11
+ class ONSCLIENT_API ONSFactoryProperty{
12
+ public:
13
+ ONSFactoryProperty();
14
+ virtual ~ONSFactoryProperty();
15
+ bool checkValidityOfFactoryProperties(const std::string& key, const std::string& value);
16
+ void setSendMsgTimeout(const int value);
17
+ void setOnsChannel(ONSChannel onsChannel);
18
+ void setFactoryProperty(CONSTSTRING& key, CONSTSTRING value);
19
+ void setFactoryProperties(std::map<std::string, std::string> factoryProperties);
20
+ std::map<std::string, std::string> getFactoryProperties() const;
21
+ CONSTSTRING getProducerId() const;
22
+ CONSTSTRING getConsumerId() const;
23
+ CONSTSTRING getPublishTopics() const;
24
+ CONSTSTRING getMessageModel() const;
25
+ const int getMessageTimeout() const;
26
+ const int getConsumeThreadNums() const;
27
+ const ONSChannel getOnsChannel() const;
28
+ CONSTSTRING getChannel() const;
29
+ CONSTSTRING getMessageContent() const;
30
+ CONSTSTRING getNameSrvAddr() const;
31
+ CONSTSTRING getNameSrvDomain() const;
32
+ CONSTSTRING getAccessKey() const;
33
+ CONSTSTRING getSecretKey() const;
34
+ public:
35
+ static CONSTSTRING ProducerId;
36
+ static CONSTSTRING ConsumerId;
37
+ static CONSTSTRING PublishTopics;
38
+ static CONSTSTRING MsgContent;
39
+ static CONSTSTRING ONSAddr;
40
+ static CONSTSTRING AccessKey;
41
+ static CONSTSTRING SecretKey;
42
+ static CONSTSTRING MessageModel;
43
+ static CONSTSTRING BROADCASTING;
44
+ static CONSTSTRING CLUSTERING;
45
+ static CONSTSTRING SendMsgTimeoutMillis;
46
+ static CONSTSTRING NAMESRV_ADDR;
47
+ static CONSTSTRING ConsumeThreadNums;
48
+ static CONSTSTRING OnsChannel;
49
+ private:
50
+ std::map<std::string, std::string> m_onsFactoryProperties;
51
+ };
52
+
53
+ class ONSCLIENT_API ONSFactoryAPI{
54
+ public:
55
+ ONSFactoryAPI();
56
+ virtual ~ONSFactoryAPI();
57
+
58
+ virtual Producer* createProducer(ONSFactoryProperty factoryProperty);
59
+ virtual TransactionProducer* createTransactionProducer(ONSFactoryProperty factoryProperty, LocalTransactionChecker *checker);
60
+ virtual PushConsumer* createPushConsumer(ONSFactoryProperty factoryProperty);
61
+ };
62
+
63
+ class ONSCLIENT_API ONSFactory{
64
+ public:
65
+ virtual ~ONSFactory();
66
+ static ONSFactoryAPI* getInstance();
67
+ private:
68
+ ONSFactory();
69
+ static ONSFactoryAPI *onsFactoryInstance;
70
+ };
71
+ }
72
+ #endif
73
+
@@ -0,0 +1,29 @@
1
+ #ifndef __PRODUCER_H__
2
+ #define __PRODUCER_H__
3
+
4
+
5
+ #include "SendResultONS.h"
6
+ #include "Message.h"
7
+
8
+
9
+ namespace ons {
10
+
11
+ class ONSCLIENT_API Producer{
12
+
13
+ public:
14
+
15
+ Producer(){}
16
+ virtual ~Producer(){}
17
+
18
+ //before send msg, start must be called to allocate resources.
19
+ virtual void start()=0;
20
+ //before exit ons, shutdown must be called to release all resources allocated by ons internally.
21
+ virtual void shutdown()=0;
22
+ //retry max 3 times if send failed. if no exception throwed, it sends success;
23
+ virtual SendResultONS send(Message& msg)=0;
24
+
25
+ };
26
+
27
+ }
28
+ #endif
29
+
@@ -0,0 +1,22 @@
1
+ #ifndef __PUSHCONSUMER_H__
2
+ #define __PUSHCONSUMER_H__
3
+
4
+ #include "MessageListener.h"
5
+
6
+ namespace ons {
7
+
8
+ class ONSCLIENT_API PushConsumer{
9
+
10
+ public:
11
+ PushConsumer(){}
12
+ virtual ~PushConsumer(){}
13
+
14
+ virtual void start()=0;
15
+ virtual void shutdown()=0;
16
+ virtual void subscribe(CONSTSTRING topic, CONSTSTRING subExpression, MessageListener* listener)=0;
17
+ //virtual void setNamesrvAddr(const std::string& nameSrvAddr) = 0;
18
+ };
19
+
20
+ }
21
+ #endif
22
+
@@ -0,0 +1,22 @@
1
+ #ifndef __SENDRESULTONS_H__
2
+ #define __SENDRESULTONS_H__
3
+
4
+ #include "ONSClient.h"
5
+
6
+ namespace ons{
7
+
8
+ class ONSCLIENT_API SendResultONS{
9
+ public:
10
+ SendResultONS();
11
+ virtual ~SendResultONS();
12
+ void setMessageId(const std::string& msgId);
13
+ CONSTSTRING getMessageId() const;
14
+
15
+
16
+ private:
17
+ std::string messageId;
18
+
19
+ };
20
+
21
+ }
22
+ #endif
@@ -0,0 +1,22 @@
1
+ #ifndef __TRANSACTIONPRODUCER_H__
2
+ #define __TRANSACTIONPRODUCER_H__
3
+
4
+ #include "LocalTransactionExecuter.h"
5
+
6
+ namespace ons{
7
+ class TransactionProducer{
8
+ public:
9
+ TransactionProducer(){}
10
+ virtual ~TransactionProducer(){}
11
+
12
+ //before send msg, start must be called to allocate resources.
13
+ virtual void start()=0;
14
+ //before exit ons, shutdown must be called to release all resources allocated by ons internally.
15
+ virtual void shutdown()=0;
16
+ //retry max 3 times if send failed. if no exception throwed, it sends success;
17
+ virtual SendResultONS send(Message& msg, LocalTransactionExecuter *executer)=0;
18
+ };
19
+ }
20
+
21
+ #endif
22
+
@@ -0,0 +1,15 @@
1
+ #ifndef __TRANSACTIONSTATUS_H__
2
+ #define __TRANSACTIONSTATUS_H__
3
+
4
+ namespace ons {
5
+
6
+ enum TransactionStatus {
7
+ CommitTransaction=0,//Ìá½»ÊÂÎñ
8
+ RollbackTransaction=1,//»Ø¹öÊÂÎñ
9
+ Unknow=2,//δ֪״̬£¬Ò»°ãÔÚÓû§ÎÞ·¨È·¶¨ÊÂÎñÊdzɹ¦»¹ÊÇʧ°ÜʱʹÓÃ
10
+ };
11
+
12
+
13
+ }
14
+
15
+ #endif