add front demo in this project
This commit is contained in:
40
LFtid1056/cloudfront/code/rocketmq/Arg_helper.h
Normal file
40
LFtid1056/cloudfront/code/rocketmq/Arg_helper.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ARG_HELPER_H_
|
||||
#define _ARG_HELPER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class ROCKETMQCLIENT_API Arg_helper {
|
||||
public:
|
||||
Arg_helper(int argc, char* argv[]);
|
||||
Arg_helper(std::string arg_str_);
|
||||
std::string get_option(int idx_) const;
|
||||
bool is_enable_option(std::string opt_) const;
|
||||
std::string get_option_value(std::string opt_) const;
|
||||
|
||||
private:
|
||||
std::vector<std::string> m_args;
|
||||
};
|
||||
|
||||
} // namespace rocketmq
|
||||
|
||||
#endif //<!_ARG_HELPER_H_;
|
||||
54
LFtid1056/cloudfront/code/rocketmq/AsyncCallback.h
Normal file
54
LFtid1056/cloudfront/code/rocketmq/AsyncCallback.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __SENDCALLBACK_H__
|
||||
#define __SENDCALLBACK_H__
|
||||
|
||||
#include "MQClientException.h"
|
||||
#include "PullResult.h"
|
||||
#include "RocketMQClient.h"
|
||||
#include "SendResult.h"
|
||||
|
||||
namespace rocketmq {
|
||||
struct AsyncCallback {};
|
||||
typedef enum sendCallbackType { noAutoDeleteSendCallback = 0, autoDeleteSendCallback = 1 } sendCallbackType;
|
||||
|
||||
class ROCKETMQCLIENT_API SendCallback : public AsyncCallback {
|
||||
public:
|
||||
virtual ~SendCallback() {}
|
||||
virtual void onSuccess(SendResult& sendResult) = 0;
|
||||
virtual void onException(MQException& e) = 0;
|
||||
virtual sendCallbackType getSendCallbackType() { return noAutoDeleteSendCallback; }
|
||||
};
|
||||
|
||||
// async SendCallback will be deleted automatically by rocketmq cpp after invoke callback interface
|
||||
class ROCKETMQCLIENT_API AutoDeleteSendCallBack : public SendCallback {
|
||||
public:
|
||||
virtual ~AutoDeleteSendCallBack() {}
|
||||
virtual void onSuccess(SendResult& sendResult) = 0;
|
||||
virtual void onException(MQException& e) = 0;
|
||||
virtual sendCallbackType getSendCallbackType() { return autoDeleteSendCallback; }
|
||||
};
|
||||
|
||||
class ROCKETMQCLIENT_API PullCallback : public AsyncCallback {
|
||||
public:
|
||||
virtual ~PullCallback() {}
|
||||
virtual void onSuccess(MQMessageQueue& mq, PullResult& result, bool bProducePullRequest) = 0;
|
||||
virtual void onException(MQException& e) = 0;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
36
LFtid1056/cloudfront/code/rocketmq/CBatchMessage.h
Normal file
36
LFtid1056/cloudfront/code/rocketmq/CBatchMessage.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_BATCHMESSAGE_H__
|
||||
#define __C_BATCHMESSAGE_H__
|
||||
#include "CCommon.h"
|
||||
#include "CMessage.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct CBatchMessage CBatchMessage;
|
||||
|
||||
ROCKETMQCLIENT_API CBatchMessage* CreateBatchMessage();
|
||||
ROCKETMQCLIENT_API int AddMessage(CBatchMessage* batchMsg, CMessage* msg);
|
||||
ROCKETMQCLIENT_API int DestroyBatchMessage(CBatchMessage* batchMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_BATCHMESSAGE_H__
|
||||
91
LFtid1056/cloudfront/code/rocketmq/CCommon.h
Normal file
91
LFtid1056/cloudfront/code/rocketmq/CCommon.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_COMMON_H__
|
||||
#define __C_COMMON_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAX_MESSAGE_ID_LENGTH 256
|
||||
#define MAX_TOPIC_LENGTH 512
|
||||
#define MAX_BROKER_NAME_ID_LENGTH 256
|
||||
#define MAX_SDK_VERSION_LENGTH 256
|
||||
#define DEFAULT_SDK_VERSION "DefaultVersion"
|
||||
typedef enum _CStatus_ {
|
||||
// Success
|
||||
OK = 0,
|
||||
// Failed, null pointer value
|
||||
NULL_POINTER = 1,
|
||||
MALLOC_FAILED = 2,
|
||||
PRODUCER_ERROR_CODE_START = 10,
|
||||
PRODUCER_START_FAILED = 10,
|
||||
PRODUCER_SEND_SYNC_FAILED = 11,
|
||||
PRODUCER_SEND_ONEWAY_FAILED = 12,
|
||||
PRODUCER_SEND_ORDERLY_FAILED = 13,
|
||||
PRODUCER_SEND_ASYNC_FAILED = 14,
|
||||
PRODUCER_SEND_ORDERLYASYNC_FAILED = 15,
|
||||
PRODUCER_SEND_TRANSACTION_FAILED = 16,
|
||||
|
||||
PUSHCONSUMER_ERROR_CODE_START = 20,
|
||||
PUSHCONSUMER_START_FAILED = 20,
|
||||
|
||||
PULLCONSUMER_ERROR_CODE_START = 30,
|
||||
PULLCONSUMER_START_FAILED = 30,
|
||||
PULLCONSUMER_FETCH_MQ_FAILED = 31,
|
||||
PULLCONSUMER_FETCH_MESSAGE_FAILED = 32,
|
||||
|
||||
Not_Support = 500,
|
||||
NOT_SUPPORT_NOW = -1
|
||||
} CStatus;
|
||||
|
||||
typedef enum _CLogLevel_ {
|
||||
E_LOG_LEVEL_FATAL = 1,
|
||||
E_LOG_LEVEL_ERROR = 2,
|
||||
E_LOG_LEVEL_WARN = 3,
|
||||
E_LOG_LEVEL_INFO = 4,
|
||||
E_LOG_LEVEL_DEBUG = 5,
|
||||
E_LOG_LEVEL_TRACE = 6,
|
||||
E_LOG_LEVEL_LEVEL_NUM = 7
|
||||
} CLogLevel;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef ROCKETMQCLIENT_EXPORTS
|
||||
#ifdef _WINDLL
|
||||
#define ROCKETMQCLIENT_API __declspec(dllexport)
|
||||
#else
|
||||
#define ROCKETMQCLIENT_API
|
||||
#endif
|
||||
#else
|
||||
#ifdef ROCKETMQCLIENT_IMPORT
|
||||
#define ROCKETMQCLIENT_API __declspec(dllimport)
|
||||
#else
|
||||
#define ROCKETMQCLIENT_API
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define ROCKETMQCLIENT_API
|
||||
#endif
|
||||
|
||||
typedef enum _CMessageModel_ { BROADCASTING, CLUSTERING } CMessageModel;
|
||||
typedef enum _CTraceModel_ { OPEN, CLOSE } CTraceModel;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_COMMON_H__
|
||||
32
LFtid1056/cloudfront/code/rocketmq/CErrorMessage.h
Normal file
32
LFtid1056/cloudfront/code/rocketmq/CErrorMessage.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CERROR_MESSAGE_H__
|
||||
#define __CERROR_MESSAGE_H__
|
||||
|
||||
#include "CCommon.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ROCKETMQCLIENT_API const char* GetLatestErrorMessage(); // Return the last error message
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__CERROR_MESSAGE_H__
|
||||
40
LFtid1056/cloudfront/code/rocketmq/CMQException.h
Normal file
40
LFtid1056/cloudfront/code/rocketmq/CMQException.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __C_MQEXCPTION_H__
|
||||
#define __C_MQEXCPTION_H__
|
||||
#include "CCommon.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAX_EXEPTION_MSG_LENGTH 512
|
||||
#define MAX_EXEPTION_FILE_LENGTH 256
|
||||
#define MAX_EXEPTION_TYPE_LENGTH 128
|
||||
typedef struct _CMQException_ {
|
||||
int error;
|
||||
int line;
|
||||
char file[MAX_EXEPTION_FILE_LENGTH];
|
||||
char msg[MAX_EXEPTION_MSG_LENGTH];
|
||||
char type[MAX_EXEPTION_TYPE_LENGTH];
|
||||
|
||||
} CMQException;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
48
LFtid1056/cloudfront/code/rocketmq/CMessage.h
Normal file
48
LFtid1056/cloudfront/code/rocketmq/CMessage.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_MESSAGE_H__
|
||||
#define __C_MESSAGE_H__
|
||||
#include "CCommon.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// typedef struct _CMessage_ CMessage;
|
||||
typedef struct CMessage CMessage;
|
||||
|
||||
ROCKETMQCLIENT_API CMessage* CreateMessage(const char* topic);
|
||||
ROCKETMQCLIENT_API int DestroyMessage(CMessage* msg);
|
||||
ROCKETMQCLIENT_API int SetMessageTopic(CMessage* msg, const char* topic);
|
||||
ROCKETMQCLIENT_API int SetMessageTags(CMessage* msg, const char* tags);
|
||||
ROCKETMQCLIENT_API int SetMessageKeys(CMessage* msg, const char* keys);
|
||||
ROCKETMQCLIENT_API int SetMessageBody(CMessage* msg, const char* body);
|
||||
ROCKETMQCLIENT_API int SetByteMessageBody(CMessage* msg, const char* body, int len);
|
||||
ROCKETMQCLIENT_API int SetMessageProperty(CMessage* msg, const char* key, const char* value);
|
||||
ROCKETMQCLIENT_API int SetDelayTimeLevel(CMessage* msg, int level);
|
||||
ROCKETMQCLIENT_API const char* GetOriginMessageTopic(CMessage* msg);
|
||||
ROCKETMQCLIENT_API const char* GetOriginMessageTags(CMessage* msg);
|
||||
ROCKETMQCLIENT_API const char* GetOriginMessageKeys(CMessage* msg);
|
||||
ROCKETMQCLIENT_API const char* GetOriginMessageBody(CMessage* msg);
|
||||
ROCKETMQCLIENT_API const char* GetOriginMessageProperty(CMessage* msg, const char* key);
|
||||
ROCKETMQCLIENT_API int GetOriginDelayTimeLevel(CMessage* msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_MESSAGE_H__
|
||||
49
LFtid1056/cloudfront/code/rocketmq/CMessageExt.h
Normal file
49
LFtid1056/cloudfront/code/rocketmq/CMessageExt.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_MESSAGE_EXT_H__
|
||||
#define __C_MESSAGE_EXT_H__
|
||||
|
||||
#include "CCommon.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// typedef struct _CMessageExt_ _CMessageExt;
|
||||
typedef struct CMessageExt CMessageExt;
|
||||
|
||||
ROCKETMQCLIENT_API const char* GetMessageTopic(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API const char* GetMessageTags(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API const char* GetMessageKeys(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API const char* GetMessageBody(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API const char* GetMessageProperty(CMessageExt* msgExt, const char* key);
|
||||
ROCKETMQCLIENT_API const char* GetMessageId(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API int GetMessageDelayTimeLevel(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API int GetMessageQueueId(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API int GetMessageReconsumeTimes(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API int GetMessageStoreSize(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API long long GetMessageBornTimestamp(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API long long GetMessageStoreTimestamp(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API long long GetMessageQueueOffset(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API long long GetMessageCommitLogOffset(CMessageExt* msgExt);
|
||||
ROCKETMQCLIENT_API long long GetMessagePreparedTransactionOffset(CMessageExt* msgExt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_MESSAGE_EXT_H__
|
||||
36
LFtid1056/cloudfront/code/rocketmq/CMessageQueue.h
Normal file
36
LFtid1056/cloudfront/code/rocketmq/CMessageQueue.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_MESSAGE_QUEUE_H__
|
||||
#define __C_MESSAGE_QUEUE_H__
|
||||
|
||||
#include "CCommon.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _CMessageQueue_ {
|
||||
char topic[MAX_TOPIC_LENGTH];
|
||||
char brokerName[MAX_BROKER_NAME_ID_LENGTH];
|
||||
int queueId;
|
||||
} CMessageQueue;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_MESSAGE_H__
|
||||
109
LFtid1056/cloudfront/code/rocketmq/CProducer.h
Normal file
109
LFtid1056/cloudfront/code/rocketmq/CProducer.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_PRODUCER_H__
|
||||
#define __C_PRODUCER_H__
|
||||
|
||||
#include "CBatchMessage.h"
|
||||
#include "CMQException.h"
|
||||
#include "CMessage.h"
|
||||
#include "CMessageExt.h"
|
||||
#include "CSendResult.h"
|
||||
#include "CTransactionStatus.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// typedef struct _CProducer_ _CProducer;
|
||||
typedef struct CProducer CProducer;
|
||||
typedef int (*QueueSelectorCallback)(int size, CMessage* msg, void* arg);
|
||||
typedef void (*CSendSuccessCallback)(CSendResult result);
|
||||
typedef void (*CSendExceptionCallback)(CMQException e);
|
||||
typedef void (*COnSendSuccessCallback)(CSendResult result, CMessage* msg, void* userData);
|
||||
typedef void (*COnSendExceptionCallback)(CMQException e, CMessage* msg, void* userData);
|
||||
typedef CTransactionStatus (*CLocalTransactionCheckerCallback)(CProducer* producer, CMessageExt* msg, void* data);
|
||||
typedef CTransactionStatus (*CLocalTransactionExecutorCallback)(CProducer* producer, CMessage* msg, void* data);
|
||||
|
||||
ROCKETMQCLIENT_API CProducer* CreateProducer(const char* groupId);
|
||||
ROCKETMQCLIENT_API CProducer* CreateOrderlyProducer(const char* groupId);
|
||||
ROCKETMQCLIENT_API CProducer* CreateTransactionProducer(const char* groupId,
|
||||
CLocalTransactionCheckerCallback callback,
|
||||
void* userData);
|
||||
ROCKETMQCLIENT_API int DestroyProducer(CProducer* producer);
|
||||
ROCKETMQCLIENT_API int StartProducer(CProducer* producer);
|
||||
ROCKETMQCLIENT_API int ShutdownProducer(CProducer* producer);
|
||||
ROCKETMQCLIENT_API const char* ShowProducerVersion(CProducer* producer);
|
||||
|
||||
ROCKETMQCLIENT_API int SetProducerNameServerAddress(CProducer* producer, const char* namesrv);
|
||||
ROCKETMQCLIENT_API int SetProducerNameServerDomain(CProducer* producer, const char* domain);
|
||||
ROCKETMQCLIENT_API int SetProducerGroupName(CProducer* producer, const char* groupName);
|
||||
ROCKETMQCLIENT_API int SetProducerInstanceName(CProducer* producer, const char* instanceName);
|
||||
ROCKETMQCLIENT_API int SetProducerSessionCredentials(CProducer* producer,
|
||||
const char* accessKey,
|
||||
const char* secretKey,
|
||||
const char* onsChannel);
|
||||
ROCKETMQCLIENT_API int SetProducerLogPath(CProducer* producer, const char* logPath);
|
||||
ROCKETMQCLIENT_API int SetProducerLogFileNumAndSize(CProducer* producer, int fileNum, long fileSize);
|
||||
ROCKETMQCLIENT_API int SetProducerLogLevel(CProducer* producer, CLogLevel level);
|
||||
ROCKETMQCLIENT_API int SetProducerSendMsgTimeout(CProducer* producer, int timeout);
|
||||
ROCKETMQCLIENT_API int SetProducerCompressLevel(CProducer* producer, int level);
|
||||
ROCKETMQCLIENT_API int SetProducerMaxMessageSize(CProducer* producer, int size);
|
||||
ROCKETMQCLIENT_API int SetProducerMessageTrace(CProducer* consumer, CTraceModel openTrace);
|
||||
|
||||
ROCKETMQCLIENT_API int SendMessageSync(CProducer* producer, CMessage* msg, CSendResult* result);
|
||||
ROCKETMQCLIENT_API int SendBatchMessage(CProducer* producer, CBatchMessage* msg, CSendResult* result);
|
||||
ROCKETMQCLIENT_API int SendMessageAsync(CProducer* producer,
|
||||
CMessage* msg,
|
||||
CSendSuccessCallback cSendSuccessCallback,
|
||||
CSendExceptionCallback cSendExceptionCallback);
|
||||
ROCKETMQCLIENT_API int SendAsync(CProducer* producer,
|
||||
CMessage* msg,
|
||||
COnSendSuccessCallback cSendSuccessCallback,
|
||||
COnSendExceptionCallback cSendExceptionCallback,
|
||||
void* userData);
|
||||
ROCKETMQCLIENT_API int SendMessageOneway(CProducer* producer, CMessage* msg);
|
||||
ROCKETMQCLIENT_API int SendMessageOnewayOrderly(CProducer* producer,
|
||||
CMessage* msg,
|
||||
QueueSelectorCallback selector,
|
||||
void* arg);
|
||||
ROCKETMQCLIENT_API int SendMessageOrderly(CProducer* producer,
|
||||
CMessage* msg,
|
||||
QueueSelectorCallback callback,
|
||||
void* arg,
|
||||
int autoRetryTimes,
|
||||
CSendResult* result);
|
||||
|
||||
ROCKETMQCLIENT_API int SendMessageOrderlyAsync(CProducer* producer,
|
||||
CMessage* msg,
|
||||
QueueSelectorCallback callback,
|
||||
void* arg,
|
||||
CSendSuccessCallback cSendSuccessCallback,
|
||||
CSendExceptionCallback cSendExceptionCallback);
|
||||
ROCKETMQCLIENT_API int SendMessageOrderlyByShardingKey(CProducer* producer,
|
||||
CMessage* msg,
|
||||
const char* shardingKey,
|
||||
CSendResult* result);
|
||||
ROCKETMQCLIENT_API int SendMessageTransaction(CProducer* producer,
|
||||
CMessage* msg,
|
||||
CLocalTransactionExecutorCallback callback,
|
||||
void* userData,
|
||||
CSendResult* result);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_PRODUCER_H__
|
||||
63
LFtid1056/cloudfront/code/rocketmq/CPullConsumer.h
Normal file
63
LFtid1056/cloudfront/code/rocketmq/CPullConsumer.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_PULL_CONSUMER_H__
|
||||
#define __C_PULL_CONSUMER_H__
|
||||
|
||||
#include "CCommon.h"
|
||||
#include "CMessageExt.h"
|
||||
#include "CMessageQueue.h"
|
||||
#include "CPullResult.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct CPullConsumer CPullConsumer;
|
||||
|
||||
ROCKETMQCLIENT_API CPullConsumer* CreatePullConsumer(const char* groupId);
|
||||
ROCKETMQCLIENT_API int DestroyPullConsumer(CPullConsumer* consumer);
|
||||
ROCKETMQCLIENT_API int StartPullConsumer(CPullConsumer* consumer);
|
||||
ROCKETMQCLIENT_API int ShutdownPullConsumer(CPullConsumer* consumer);
|
||||
ROCKETMQCLIENT_API const char* ShowPullConsumerVersion(CPullConsumer* consumer);
|
||||
|
||||
ROCKETMQCLIENT_API int SetPullConsumerGroupID(CPullConsumer* consumer, const char* groupId);
|
||||
ROCKETMQCLIENT_API const char* GetPullConsumerGroupID(CPullConsumer* consumer);
|
||||
ROCKETMQCLIENT_API int SetPullConsumerNameServerAddress(CPullConsumer* consumer, const char* namesrv);
|
||||
ROCKETMQCLIENT_API int SetPullConsumerNameServerDomain(CPullConsumer* consumer, const char* domain);
|
||||
ROCKETMQCLIENT_API int SetPullConsumerSessionCredentials(CPullConsumer* consumer,
|
||||
const char* accessKey,
|
||||
const char* secretKey,
|
||||
const char* channel);
|
||||
ROCKETMQCLIENT_API int SetPullConsumerLogPath(CPullConsumer* consumer, const char* logPath);
|
||||
ROCKETMQCLIENT_API int SetPullConsumerLogFileNumAndSize(CPullConsumer* consumer, int fileNum, long fileSize);
|
||||
ROCKETMQCLIENT_API int SetPullConsumerLogLevel(CPullConsumer* consumer, CLogLevel level);
|
||||
|
||||
ROCKETMQCLIENT_API int FetchSubscriptionMessageQueues(CPullConsumer* consumer,
|
||||
const char* topic,
|
||||
CMessageQueue** mqs,
|
||||
int* size);
|
||||
ROCKETMQCLIENT_API int ReleaseSubscriptionMessageQueue(CMessageQueue* mqs);
|
||||
|
||||
ROCKETMQCLIENT_API CPullResult
|
||||
Pull(CPullConsumer* consumer, const CMessageQueue* mq, const char* subExpression, long long offset, int maxNums);
|
||||
ROCKETMQCLIENT_API int ReleasePullResult(CPullResult pullResult);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_PUSH_CONSUMER_H__
|
||||
48
LFtid1056/cloudfront/code/rocketmq/CPullResult.h
Normal file
48
LFtid1056/cloudfront/code/rocketmq/CPullResult.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_PULL_RESULT_H__
|
||||
#define __C_PULL_RESULT_H__
|
||||
|
||||
#include "CCommon.h"
|
||||
#include "CMessageExt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef enum E_CPullStatus {
|
||||
E_FOUND,
|
||||
E_NO_NEW_MSG,
|
||||
E_NO_MATCHED_MSG,
|
||||
E_OFFSET_ILLEGAL,
|
||||
E_BROKER_TIMEOUT // indicate pull request timeout or received NULL response
|
||||
} CPullStatus;
|
||||
|
||||
typedef struct _CPullResult_ {
|
||||
CPullStatus pullStatus;
|
||||
long long nextBeginOffset;
|
||||
long long minOffset;
|
||||
long long maxOffset;
|
||||
CMessageExt** msgFoundList;
|
||||
int size;
|
||||
void* pData;
|
||||
} CPullResult;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_PULL_RESULT_H__
|
||||
67
LFtid1056/cloudfront/code/rocketmq/CPushConsumer.h
Normal file
67
LFtid1056/cloudfront/code/rocketmq/CPushConsumer.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_PUSH_CONSUMER_H__
|
||||
#define __C_PUSH_CONSUMER_H__
|
||||
|
||||
#include "CCommon.h"
|
||||
#include "CMessageExt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// typedef struct _CConsumer_ _CConsumer;
|
||||
typedef struct CPushConsumer CPushConsumer;
|
||||
|
||||
typedef enum E_CConsumeStatus { E_CONSUME_SUCCESS = 0, E_RECONSUME_LATER = 1 } CConsumeStatus;
|
||||
|
||||
typedef int (*MessageCallBack)(CPushConsumer*, CMessageExt*);
|
||||
|
||||
ROCKETMQCLIENT_API CPushConsumer* CreatePushConsumer(const char* groupId);
|
||||
ROCKETMQCLIENT_API int DestroyPushConsumer(CPushConsumer* consumer);
|
||||
ROCKETMQCLIENT_API int StartPushConsumer(CPushConsumer* consumer);
|
||||
ROCKETMQCLIENT_API int ShutdownPushConsumer(CPushConsumer* consumer);
|
||||
ROCKETMQCLIENT_API const char* ShowPushConsumerVersion(CPushConsumer* consumer);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerGroupID(CPushConsumer* consumer, const char* groupId);
|
||||
ROCKETMQCLIENT_API const char* GetPushConsumerGroupID(CPushConsumer* consumer);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerNameServerAddress(CPushConsumer* consumer, const char* namesrv);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerNameServerDomain(CPushConsumer* consumer, const char* domain);
|
||||
ROCKETMQCLIENT_API int Subscribe(CPushConsumer* consumer, const char* topic, const char* expression);
|
||||
ROCKETMQCLIENT_API int RegisterMessageCallbackOrderly(CPushConsumer* consumer, MessageCallBack pCallback);
|
||||
ROCKETMQCLIENT_API int RegisterMessageCallback(CPushConsumer* consumer, MessageCallBack pCallback);
|
||||
ROCKETMQCLIENT_API int UnregisterMessageCallbackOrderly(CPushConsumer* consumer);
|
||||
ROCKETMQCLIENT_API int UnregisterMessageCallback(CPushConsumer* consumer);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerThreadCount(CPushConsumer* consumer, int threadCount);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerMessageBatchMaxSize(CPushConsumer* consumer, int batchSize);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerInstanceName(CPushConsumer* consumer, const char* instanceName);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerSessionCredentials(CPushConsumer* consumer,
|
||||
const char* accessKey,
|
||||
const char* secretKey,
|
||||
const char* channel);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerLogPath(CPushConsumer* consumer, const char* logPath);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerLogFileNumAndSize(CPushConsumer* consumer, int fileNum, long fileSize);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerLogLevel(CPushConsumer* consumer, CLogLevel level);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerMessageModel(CPushConsumer* consumer, CMessageModel messageModel);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerMaxCacheMessageSize(CPushConsumer* consumer, int maxCacheSize);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerMaxCacheMessageSizeInMb(CPushConsumer* consumer, int maxCacheSizeInMb);
|
||||
ROCKETMQCLIENT_API int SetPushConsumerMessageTrace(CPushConsumer* consumer, CTraceModel openTrace);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_PUSH_CONSUMER_H__
|
||||
42
LFtid1056/cloudfront/code/rocketmq/CSendResult.h
Normal file
42
LFtid1056/cloudfront/code/rocketmq/CSendResult.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_SEND_RESULT_H__
|
||||
#define __C_SEND_RESULT_H__
|
||||
|
||||
#include "CCommon.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum E_CSendStatus_ {
|
||||
E_SEND_OK = 0,
|
||||
E_SEND_FLUSH_DISK_TIMEOUT = 1,
|
||||
E_SEND_FLUSH_SLAVE_TIMEOUT = 2,
|
||||
E_SEND_SLAVE_NOT_AVAILABLE = 3
|
||||
} CSendStatus;
|
||||
|
||||
typedef struct _SendResult_ {
|
||||
CSendStatus sendStatus;
|
||||
char msgId[MAX_MESSAGE_ID_LENGTH];
|
||||
long long offset;
|
||||
} CSendResult;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_PRODUCER_H__
|
||||
33
LFtid1056/cloudfront/code/rocketmq/CTransactionStatus.h
Normal file
33
LFtid1056/cloudfront/code/rocketmq/CTransactionStatus.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __C_TRANSACTION_STATUS_H__
|
||||
#define __C_TRANSACTION_STATUS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
typedef enum E_CTransactionStatus {
|
||||
E_COMMIT_TRANSACTION = 0,
|
||||
E_ROLLBACK_TRANSACTION = 1,
|
||||
E_UNKNOWN_TRANSACTION = 2,
|
||||
} CTransactionStatus;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //__C_TRANSACTION_STATUS_H__
|
||||
61
LFtid1056/cloudfront/code/rocketmq/ConsumeType.h
Normal file
61
LFtid1056/cloudfront/code/rocketmq/ConsumeType.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CONSUMETYPE_H__
|
||||
#define __CONSUMETYPE_H__
|
||||
|
||||
namespace rocketmq {
|
||||
//<!***************************************************************************
|
||||
enum ConsumeType {
|
||||
CONSUME_ACTIVELY,
|
||||
CONSUME_PASSIVELY,
|
||||
};
|
||||
|
||||
//<!***************************************************************************
|
||||
enum ConsumeFromWhere {
|
||||
/**
|
||||
*new consumer will consume from end offset of queue,
|
||||
* and then consume from last consumed offset of queue follow-up
|
||||
*/
|
||||
CONSUME_FROM_LAST_OFFSET,
|
||||
|
||||
// @Deprecated
|
||||
CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST,
|
||||
// @Deprecated
|
||||
CONSUME_FROM_MIN_OFFSET,
|
||||
// @Deprecated
|
||||
CONSUME_FROM_MAX_OFFSET,
|
||||
/**
|
||||
*new consumer will consume from first offset of queue,
|
||||
* and then consume from last consumed offset of queue follow-up
|
||||
*/
|
||||
CONSUME_FROM_FIRST_OFFSET,
|
||||
/**
|
||||
*new consumer will consume from the queue offset specified by timestamp,
|
||||
* and then consume from last consumed offset of queue follow-up
|
||||
*/
|
||||
CONSUME_FROM_TIMESTAMP,
|
||||
};
|
||||
|
||||
//<!***************************************************************************
|
||||
enum MessageModel {
|
||||
BROADCASTING,
|
||||
CLUSTERING,
|
||||
};
|
||||
//<!***************************************************************************
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
146
LFtid1056/cloudfront/code/rocketmq/DefaultMQProducer.h
Normal file
146
LFtid1056/cloudfront/code/rocketmq/DefaultMQProducer.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __DEFAULTMQPRODUCER_H__
|
||||
#define __DEFAULTMQPRODUCER_H__
|
||||
|
||||
#include "AsyncCallback.h"
|
||||
#include "MQClient.h"
|
||||
#include "MQMessageQueue.h"
|
||||
#include "MQSelector.h"
|
||||
#include "RocketMQClient.h"
|
||||
#include "SendResult.h"
|
||||
#include "SessionCredentials.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class DefaultMQProducerImpl;
|
||||
class ROCKETMQCLIENT_API DefaultMQProducer {
|
||||
public:
|
||||
DefaultMQProducer(const std::string& groupname);
|
||||
virtual ~DefaultMQProducer();
|
||||
|
||||
virtual void start();
|
||||
virtual void shutdown();
|
||||
virtual std::string version();
|
||||
|
||||
virtual SendResult send(MQMessage& msg, bool bSelectActiveBroker = false);
|
||||
virtual SendResult send(MQMessage& msg, const MQMessageQueue& mq);
|
||||
virtual SendResult send(MQMessage& msg, MessageQueueSelector* selector, void* arg);
|
||||
virtual SendResult send(MQMessage& msg,
|
||||
MessageQueueSelector* selector,
|
||||
void* arg,
|
||||
int autoRetryTimes,
|
||||
bool bActiveBroker = false);
|
||||
virtual SendResult send(std::vector<MQMessage>& msgs);
|
||||
virtual SendResult send(std::vector<MQMessage>& msgs, const MQMessageQueue& mq);
|
||||
virtual void send(MQMessage& msg, SendCallback* pSendCallback, bool bSelectActiveBroker = false);
|
||||
virtual void send(MQMessage& msg, const MQMessageQueue& mq, SendCallback* pSendCallback);
|
||||
virtual void send(MQMessage& msg, MessageQueueSelector* selector, void* arg, SendCallback* pSendCallback);
|
||||
virtual void sendOneway(MQMessage& msg, bool bSelectActiveBroker = false);
|
||||
virtual void sendOneway(MQMessage& msg, const MQMessageQueue& mq);
|
||||
virtual void sendOneway(MQMessage& msg, MessageQueueSelector* selector, void* arg);
|
||||
|
||||
const std::string& getNamesrvAddr() const;
|
||||
void setNamesrvAddr(const std::string& namesrvAddr);
|
||||
|
||||
void setSessionCredentials(const std::string& accessKey,
|
||||
const std::string& secretKey,
|
||||
const std::string& accessChannel);
|
||||
const SessionCredentials& getSessionCredentials() const;
|
||||
|
||||
const std::string& getNamesrvDomain() const;
|
||||
void setNamesrvDomain(const std::string& namesrvDomain);
|
||||
|
||||
const std::string& getNameSpace() const;
|
||||
void setNameSpace(const std::string& nameSpace);
|
||||
|
||||
const std::string& getGroupName() const;
|
||||
void setGroupName(const std::string& groupname);
|
||||
|
||||
const std::string& getInstanceName() const;
|
||||
void setInstanceName(const std::string& instanceName);
|
||||
|
||||
/**
|
||||
* Log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
|
||||
* log file num is 3, each log size is 100M
|
||||
**/
|
||||
void setLogLevel(elogLevel inputLevel);
|
||||
elogLevel getLogLevel();
|
||||
void setLogPath(const std::string& logPath);
|
||||
void setLogFileSizeAndNum(int fileNum, long perFileSize); // perFileSize is MB unit
|
||||
|
||||
int getSendMsgTimeout() const;
|
||||
void setSendMsgTimeout(int sendMsgTimeout);
|
||||
|
||||
/*
|
||||
* If msgBody size is large than compressMsgBodyOverHowmuch
|
||||
* rocketmq cpp will compress msgBody according to compressLevel
|
||||
*/
|
||||
int getCompressMsgBodyOverHowmuch() const;
|
||||
void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch);
|
||||
int getCompressLevel() const;
|
||||
void setCompressLevel(int compressLevel);
|
||||
|
||||
int getMaxMessageSize() const;
|
||||
void setMaxMessageSize(int maxMessageSize);
|
||||
|
||||
int getRetryTimes() const;
|
||||
void setRetryTimes(int times);
|
||||
|
||||
int getRetryTimes4Async() const;
|
||||
void setRetryTimes4Async(int times);
|
||||
|
||||
/** Set TcpTransport pull thread num, which dermine the num of threads to
|
||||
* distribute network data,
|
||||
* 1. its default value is CPU num, it must be setted before producer/consumer
|
||||
* start, minimum value is CPU num;
|
||||
* 2. this pullThread num must be tested on your environment to find the best
|
||||
* value for RT of sendMsg or delay time of consume msg before you change it;
|
||||
* 3. producer and consumer need different pullThread num, if set this num,
|
||||
* producer and consumer must set different instanceName.
|
||||
**/
|
||||
void setTcpTransportPullThreadNum(int num);
|
||||
int getTcpTransportPullThreadNum() const;
|
||||
|
||||
/** Timeout of tcp connect, it is same meaning for both producer and consumer;
|
||||
* 1. default value is 3000ms
|
||||
* 2. input parameter could only be milliSecond, suggestion value is
|
||||
* 1000-3000ms;
|
||||
**/
|
||||
void setTcpTransportConnectTimeout(uint64_t timeout); // ms
|
||||
uint64_t getTcpTransportConnectTimeout() const;
|
||||
|
||||
/** Timeout of tryLock tcpTransport before sendMsg/pullMsg, if timeout,
|
||||
* returns NULL
|
||||
* 1. paremeter unit is ms, default value is 3000ms, the minimun value is 1000ms
|
||||
* suggestion value is 3000ms;
|
||||
* 2. if configured with value smaller than 1000ms, the tryLockTimeout value
|
||||
* will be setted to 1000ms
|
||||
**/
|
||||
void setTcpTransportTryLockTimeout(uint64_t timeout); // ms
|
||||
uint64_t getTcpTransportTryLockTimeout() const;
|
||||
|
||||
void setUnitName(std::string unitName);
|
||||
const std::string& getUnitName() const;
|
||||
void setMessageTrace(bool messageTrace);
|
||||
bool getMessageTrace() const;
|
||||
|
||||
private:
|
||||
DefaultMQProducerImpl* impl;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
146
LFtid1056/cloudfront/code/rocketmq/DefaultMQPullConsumer.h
Normal file
146
LFtid1056/cloudfront/code/rocketmq/DefaultMQPullConsumer.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __DEFAULTMQPULLCONSUMER_H__
|
||||
#define __DEFAULTMQPULLCONSUMER_H__
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include "AsyncCallback.h"
|
||||
#include "ConsumeType.h"
|
||||
#include "MQClient.h"
|
||||
#include "MQMessage.h"
|
||||
#include "MQMessageExt.h"
|
||||
#include "MQMessageQueue.h"
|
||||
#include "MQueueListener.h"
|
||||
#include "PullResult.h"
|
||||
#include "RocketMQClient.h"
|
||||
#include "SessionCredentials.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class SubscriptionData;
|
||||
class DefaultMQPullConsumerImpl;
|
||||
class ROCKETMQCLIENT_API DefaultMQPullConsumer {
|
||||
public:
|
||||
DefaultMQPullConsumer(const std::string& groupname);
|
||||
virtual ~DefaultMQPullConsumer();
|
||||
|
||||
virtual void start();
|
||||
virtual void shutdown();
|
||||
virtual std::string version();
|
||||
|
||||
const std::string& getNamesrvAddr() const;
|
||||
void setNamesrvAddr(const std::string& namesrvAddr);
|
||||
|
||||
void setSessionCredentials(const std::string& accessKey,
|
||||
const std::string& secretKey,
|
||||
const std::string& accessChannel);
|
||||
const SessionCredentials& getSessionCredentials() const;
|
||||
|
||||
const std::string& getNamesrvDomain() const;
|
||||
void setNamesrvDomain(const std::string& namesrvDomain);
|
||||
|
||||
const std::string& getInstanceName() const;
|
||||
void setInstanceName(const std::string& instanceName);
|
||||
|
||||
const std::string& getNameSpace() const;
|
||||
void setNameSpace(const std::string& nameSpace);
|
||||
|
||||
const std::string& getGroupName() const;
|
||||
void setGroupName(const std::string& groupname);
|
||||
|
||||
/**
|
||||
* Log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
|
||||
* log file num is 3, each log size is 100M
|
||||
**/
|
||||
void setLogLevel(elogLevel inputLevel);
|
||||
elogLevel getLogLevel();
|
||||
void setLogPath(const std::string& logPath);
|
||||
void setLogFileSizeAndNum(int fileNum, long perFileSize); // perFileSize is MB unit
|
||||
|
||||
virtual void fetchSubscribeMessageQueues(const std::string& topic, std::vector<MQMessageQueue>& mqs);
|
||||
|
||||
/**
|
||||
* Pull message from specified queue, if no msg in queue, return directly
|
||||
*
|
||||
* @param mq
|
||||
* specify the pulled queue
|
||||
* @param subExpression
|
||||
* set filter expression for pulled msg, broker will filter msg actively
|
||||
* Now only OR operation is supported, eg: "tag1 || tag2 || tag3"
|
||||
* if subExpression is setted to "null" or "*", all msg will be subscribed
|
||||
* @param offset
|
||||
* specify the started pull offset
|
||||
* @param maxNums
|
||||
* specify max msg num by per pull
|
||||
* @return
|
||||
* PullResult
|
||||
*/
|
||||
virtual PullResult pull(const MQMessageQueue& mq, const std::string& subExpression, int64 offset, int maxNums);
|
||||
virtual void pull(const MQMessageQueue& mq,
|
||||
const std::string& subExpression,
|
||||
int64 offset,
|
||||
int maxNums,
|
||||
PullCallback* pPullCallback);
|
||||
|
||||
/**
|
||||
* Pull msg from specified queue, if no msg, broker will suspend the pull request 20s
|
||||
*
|
||||
* @param mq
|
||||
* specify the pulled queue
|
||||
* @param subExpression
|
||||
* set filter expression for pulled msg, broker will filter msg actively
|
||||
* Now only OR operation is supported, eg: "tag1 || tag2 || tag3"
|
||||
* if subExpression is setted to "null" or "*", all msg will be subscribed
|
||||
* @param offset
|
||||
* specify the started pull offset
|
||||
* @param maxNums
|
||||
* specify max msg num by per pull
|
||||
* @return
|
||||
* accroding to PullResult
|
||||
*/
|
||||
virtual PullResult pullBlockIfNotFound(const MQMessageQueue& mq,
|
||||
const std::string& subExpression,
|
||||
int64 offset,
|
||||
int maxNums);
|
||||
virtual void pullBlockIfNotFound(const MQMessageQueue& mq,
|
||||
const std::string& subExpression,
|
||||
int64 offset,
|
||||
int maxNums,
|
||||
PullCallback* pPullCallback);
|
||||
|
||||
void persistConsumerOffset();
|
||||
void persistConsumerOffsetByResetOffset();
|
||||
void updateTopicSubscribeInfo(const std::string& topic, std::vector<MQMessageQueue>& info);
|
||||
ConsumeFromWhere getConsumeFromWhere();
|
||||
void getSubscriptions(std::vector<SubscriptionData>&);
|
||||
void updateConsumeOffset(const MQMessageQueue& mq, int64 offset);
|
||||
void removeConsumeOffset(const MQMessageQueue& mq);
|
||||
|
||||
void registerMessageQueueListener(const std::string& topic, MQueueListener* pListener);
|
||||
|
||||
int64 fetchConsumeOffset(const MQMessageQueue& mq, bool fromStore);
|
||||
|
||||
void fetchMessageQueuesInBalance(const std::string& topic, std::vector<MQMessageQueue> mqs);
|
||||
|
||||
void persistConsumerOffset4PullConsumer(const MQMessageQueue& mq);
|
||||
|
||||
private:
|
||||
DefaultMQPullConsumerImpl* impl;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
142
LFtid1056/cloudfront/code/rocketmq/DefaultMQPushConsumer.h
Normal file
142
LFtid1056/cloudfront/code/rocketmq/DefaultMQPushConsumer.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __DEFAULTMQPUSHCONSUMER_H__
|
||||
#define __DEFAULTMQPUSHCONSUMER_H__
|
||||
|
||||
#include <string>
|
||||
#include "AsyncCallback.h"
|
||||
#include "ConsumeType.h"
|
||||
#include "MQClient.h"
|
||||
#include "MQMessageListener.h"
|
||||
#include "MQMessageQueue.h"
|
||||
#include "SessionCredentials.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class DefaultMQPushConsumerImpl;
|
||||
class ROCKETMQCLIENT_API DefaultMQPushConsumer {
|
||||
public:
|
||||
DefaultMQPushConsumer(const std::string& groupname);
|
||||
|
||||
virtual ~DefaultMQPushConsumer();
|
||||
|
||||
virtual void start();
|
||||
virtual void shutdown();
|
||||
virtual std::string version();
|
||||
|
||||
const std::string& getNamesrvAddr() const;
|
||||
void setNamesrvAddr(const std::string& namesrvAddr);
|
||||
|
||||
void setSessionCredentials(const std::string& accessKey,
|
||||
const std::string& secretKey,
|
||||
const std::string& accessChannel);
|
||||
const SessionCredentials& getSessionCredentials() const;
|
||||
|
||||
void subscribe(const std::string& topic, const std::string& subExpression);
|
||||
|
||||
void registerMessageListener(MQMessageListener* pMessageListener);
|
||||
MessageListenerType getMessageListenerType();
|
||||
|
||||
MessageModel getMessageModel() const;
|
||||
void setMessageModel(MessageModel messageModel);
|
||||
|
||||
void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere);
|
||||
ConsumeFromWhere getConsumeFromWhere();
|
||||
|
||||
const std::string& getNamesrvDomain() const;
|
||||
void setNamesrvDomain(const std::string& namesrvDomain);
|
||||
|
||||
const std::string& getInstanceName() const;
|
||||
void setInstanceName(const std::string& instanceName);
|
||||
|
||||
const std::string& getNameSpace() const;
|
||||
void setNameSpace(const std::string& nameSpace);
|
||||
|
||||
const std::string& getGroupName() const;
|
||||
void setGroupName(const std::string& groupname);
|
||||
|
||||
/**
|
||||
* Log configuration interface, default LOG_LEVEL is LOG_LEVEL_INFO, default
|
||||
* log file num is 3, each log size is 100M
|
||||
**/
|
||||
void setLogLevel(elogLevel inputLevel);
|
||||
elogLevel getLogLevel();
|
||||
void setLogPath(const std::string& logPath);
|
||||
void setLogFileSizeAndNum(int fileNum, long perFileSize); // perFileSize is MB unit
|
||||
|
||||
void setConsumeThreadCount(int threadCount);
|
||||
int getConsumeThreadCount() const;
|
||||
|
||||
void setMaxReconsumeTimes(int maxReconsumeTimes);
|
||||
int getMaxReconsumeTimes() const;
|
||||
|
||||
void setPullMsgThreadPoolCount(int threadCount);
|
||||
int getPullMsgThreadPoolCount() const;
|
||||
|
||||
void setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize);
|
||||
int getConsumeMessageBatchMaxSize() const;
|
||||
|
||||
/**
|
||||
* Set max cache msg size perQueue in memory if consumer could not consume msgs
|
||||
* immediately
|
||||
* default maxCacheMsgSize perQueue is 1000, set range is:1~65535
|
||||
**/
|
||||
void setMaxCacheMsgSizePerQueue(int maxCacheSize);
|
||||
int getMaxCacheMsgSizePerQueue() const;
|
||||
|
||||
/** Set TcpTransport pull thread num, which dermine the num of threads to
|
||||
* distribute network data,
|
||||
* 1. its default value is CPU num, it must be setted before producer/consumer
|
||||
* start, minimum value is CPU num;
|
||||
* 2. this pullThread num must be tested on your environment to find the best
|
||||
* value for RT of sendMsg or delay time of consume msg before you change it;
|
||||
* 3. producer and consumer need different pullThread num, if set this num,
|
||||
* producer and consumer must set different instanceName.
|
||||
**/
|
||||
void setTcpTransportPullThreadNum(int num);
|
||||
int getTcpTransportPullThreadNum() const;
|
||||
|
||||
/** Timeout of tcp connect, it is same meaning for both producer and consumer;
|
||||
* 1. default value is 3000ms
|
||||
* 2. input parameter could only be milliSecond, suggestion value is
|
||||
* 1000-3000ms;
|
||||
**/
|
||||
void setTcpTransportConnectTimeout(uint64_t timeout); // ms
|
||||
uint64_t getTcpTransportConnectTimeout() const;
|
||||
|
||||
/** Timeout of tryLock tcpTransport before sendMsg/pullMsg, if timeout,
|
||||
* returns NULL
|
||||
* 1. paremeter unit is ms, default value is 3000ms, the minimun value is 1000ms
|
||||
* suggestion value is 3000ms;
|
||||
* 2. if configured with value smaller than 1000ms, the tryLockTimeout value
|
||||
* will be setted to 1000ms
|
||||
**/
|
||||
void setTcpTransportTryLockTimeout(uint64_t timeout); // ms
|
||||
uint64_t getTcpTransportTryLockTimeout() const;
|
||||
|
||||
void setUnitName(std::string unitName);
|
||||
const std::string& getUnitName() const;
|
||||
|
||||
void setAsyncPull(bool asyncFlag);
|
||||
void setMessageTrace(bool messageTrace);
|
||||
bool getMessageTrace() const;
|
||||
|
||||
private:
|
||||
DefaultMQPushConsumerImpl* impl;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
34
LFtid1056/cloudfront/code/rocketmq/MQClient.h
Normal file
34
LFtid1056/cloudfront/code/rocketmq/MQClient.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MQADMIN_H__
|
||||
#define __MQADMIN_H__
|
||||
|
||||
namespace rocketmq {
|
||||
|
||||
enum elogLevel {
|
||||
eLOG_LEVEL_FATAL = 1,
|
||||
eLOG_LEVEL_ERROR = 2,
|
||||
eLOG_LEVEL_WARN = 3,
|
||||
eLOG_LEVEL_INFO = 4,
|
||||
eLOG_LEVEL_DEBUG = 5,
|
||||
eLOG_LEVEL_TRACE = 6,
|
||||
eLOG_LEVEL_LEVEL_NUM = 7
|
||||
};
|
||||
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
88
LFtid1056/cloudfront/code/rocketmq/MQClientException.h
Normal file
88
LFtid1056/cloudfront/code/rocketmq/MQClientException.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __MQCLIENTEXCEPTION_H__
|
||||
#define __MQCLIENTEXCEPTION_H__
|
||||
|
||||
#include <string.h>
|
||||
#include <exception>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class ROCKETMQCLIENT_API MQException : public std::exception {
|
||||
public:
|
||||
MQException(const std::string& msg, int error, const char* file, int line) throw()
|
||||
: m_error(error), m_line(line), m_file(file) {
|
||||
try {
|
||||
std::stringstream ss;
|
||||
ss << "msg: " << msg << ",error:" << error << ",in file <" << file << "> line:" << line;
|
||||
m_msg = ss.str();
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
MQException(const std::string& msg, int error, const char* file, const char* type, int line) throw()
|
||||
: m_error(error), m_line(line), m_file(file), m_type(type) {
|
||||
try {
|
||||
std::stringstream ss;
|
||||
ss << "msg: " << msg << ",error:" << error << ",in file <" << file << "> line:" << line;
|
||||
m_msg = ss.str();
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~MQException() throw() {}
|
||||
const char* what() const throw() { return m_msg.c_str(); }
|
||||
int GetError() const throw() { return m_error; }
|
||||
virtual const char* GetType() const throw() { return m_type.c_str(); }
|
||||
int GetLine() { return m_line; }
|
||||
const char* GetFile() { return m_file.c_str(); }
|
||||
|
||||
protected:
|
||||
int m_error;
|
||||
int m_line;
|
||||
std::string m_msg;
|
||||
std::string m_file;
|
||||
std::string m_type;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const MQException& e) {
|
||||
os << "Type: " << e.GetType() << " , " << e.what();
|
||||
return os;
|
||||
}
|
||||
|
||||
#define DEFINE_MQCLIENTEXCEPTION(name) \
|
||||
class ROCKETMQCLIENT_API name : public MQException { \
|
||||
public: \
|
||||
name(const std::string& msg, int error, const char* file, int line) throw() \
|
||||
: MQException(msg, error, file, #name, line) {} \
|
||||
virtual const char* GetType() const throw() { return m_type.c_str(); } \
|
||||
};
|
||||
|
||||
DEFINE_MQCLIENTEXCEPTION(MQClientException)
|
||||
DEFINE_MQCLIENTEXCEPTION(MQBrokerException)
|
||||
DEFINE_MQCLIENTEXCEPTION(InterruptedException)
|
||||
DEFINE_MQCLIENTEXCEPTION(RemotingException)
|
||||
DEFINE_MQCLIENTEXCEPTION(UnknownHostException)
|
||||
|
||||
#define THROW_MQEXCEPTION(e, msg, err) throw e(msg, err, __FILE__, __LINE__)
|
||||
#define NEW_MQEXCEPTION(e, msg, err) e(msg, err, __FILE__, __LINE__)
|
||||
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
141
LFtid1056/cloudfront/code/rocketmq/MQMessage.h
Normal file
141
LFtid1056/cloudfront/code/rocketmq/MQMessage.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __MESSAGE_H__
|
||||
#define __MESSAGE_H__
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class ROCKETMQCLIENT_API MQMessage {
|
||||
public:
|
||||
MQMessage();
|
||||
MQMessage(const std::string& topic, const std::string& body);
|
||||
MQMessage(const std::string& topic, const std::string& tags, const std::string& body);
|
||||
MQMessage(const std::string& topic, const std::string& tags, const std::string& keys, const std::string& body);
|
||||
MQMessage(const std::string& topic,
|
||||
const std::string& tags,
|
||||
const std::string& keys,
|
||||
const int flag,
|
||||
const std::string& body,
|
||||
bool waitStoreMsgOK);
|
||||
|
||||
virtual ~MQMessage();
|
||||
MQMessage(const MQMessage& other);
|
||||
MQMessage& operator=(const MQMessage& other);
|
||||
|
||||
void setProperty(const std::string& name, const std::string& value);
|
||||
const std::string& getProperty(const std::string& name) const;
|
||||
|
||||
const std::string& getTopic() const;
|
||||
void setTopic(const std::string& topic);
|
||||
void setTopic(const char* body, int len);
|
||||
|
||||
const std::string& getTags() const;
|
||||
void setTags(const std::string& tags);
|
||||
|
||||
const std::string& getKeys() const;
|
||||
void setKeys(const std::string& keys);
|
||||
void setKeys(const std::vector<std::string>& keys);
|
||||
|
||||
int getDelayTimeLevel() const;
|
||||
void setDelayTimeLevel(int level);
|
||||
|
||||
bool isWaitStoreMsgOK() const;
|
||||
void setWaitStoreMsgOK(bool waitStoreMsgOK);
|
||||
|
||||
int getFlag() const;
|
||||
void setFlag(int flag);
|
||||
|
||||
int getSysFlag() const;
|
||||
void setSysFlag(int sysFlag);
|
||||
|
||||
const std::string& getBody() const;
|
||||
|
||||
void setBody(const char* body, int len);
|
||||
void setBody(const std::string& body);
|
||||
|
||||
void setTransactionId(const std::string& id) { m_transactionId = id; }
|
||||
std::string getTransactionId() const { return m_transactionId; }
|
||||
|
||||
std::map<std::string, std::string> getProperties() const;
|
||||
void setProperties(std::map<std::string, std::string>& properties);
|
||||
|
||||
const std::string toString() const {
|
||||
std::stringstream ss;
|
||||
std::string tags = getTags();
|
||||
ss << "Message [topic=" << m_topic << ", flag=" << m_flag << ", tag=" << tags << "]";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class MQDecoder;
|
||||
void setPropertyInternal(const std::string& name, const std::string& value);
|
||||
void setPropertiesInternal(std::map<std::string, std::string>& properties);
|
||||
|
||||
void Init(const std::string& topic,
|
||||
const std::string& tags,
|
||||
const std::string& keys,
|
||||
const int flag,
|
||||
const std::string& body,
|
||||
bool waitStoreMsgOK);
|
||||
|
||||
public:
|
||||
static const std::string PROPERTY_KEYS;
|
||||
static const std::string PROPERTY_TAGS;
|
||||
static const std::string PROPERTY_WAIT_STORE_MSG_OK;
|
||||
static const std::string PROPERTY_DELAY_TIME_LEVEL;
|
||||
static const std::string PROPERTY_RETRY_TOPIC;
|
||||
static const std::string PROPERTY_REAL_TOPIC;
|
||||
static const std::string PROPERTY_REAL_QUEUE_ID;
|
||||
static const std::string PROPERTY_TRANSACTION_PREPARED;
|
||||
static const std::string PROPERTY_PRODUCER_GROUP;
|
||||
static const std::string PROPERTY_MIN_OFFSET;
|
||||
static const std::string PROPERTY_MAX_OFFSET;
|
||||
|
||||
static const std::string PROPERTY_BUYER_ID;
|
||||
static const std::string PROPERTY_ORIGIN_MESSAGE_ID;
|
||||
static const std::string PROPERTY_TRANSFER_FLAG;
|
||||
static const std::string PROPERTY_CORRECTION_FLAG;
|
||||
static const std::string PROPERTY_MQ2_FLAG;
|
||||
static const std::string PROPERTY_RECONSUME_TIME;
|
||||
static const std::string PROPERTY_MSG_REGION;
|
||||
static const std::string PROPERTY_TRACE_SWITCH;
|
||||
static const std::string PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX;
|
||||
static const std::string PROPERTY_MAX_RECONSUME_TIMES;
|
||||
static const std::string PROPERTY_CONSUME_START_TIMESTAMP;
|
||||
static const std::string PROPERTY_TRANSACTION_PREPARED_QUEUE_OFFSET;
|
||||
static const std::string PROPERTY_TRANSACTION_CHECK_TIMES;
|
||||
static const std::string PROPERTY_CHECK_IMMUNITY_TIME_IN_SECONDS;
|
||||
|
||||
static const std::string KEY_SEPARATOR;
|
||||
|
||||
protected:
|
||||
int m_sysFlag;
|
||||
|
||||
private:
|
||||
std::string m_topic;
|
||||
int m_flag;
|
||||
std::string m_body;
|
||||
std::string m_transactionId;
|
||||
std::map<std::string, std::string> m_properties;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
115
LFtid1056/cloudfront/code/rocketmq/MQMessageExt.h
Normal file
115
LFtid1056/cloudfront/code/rocketmq/MQMessageExt.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __MESSAGEEXT_H__
|
||||
#define __MESSAGEEXT_H__
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#include <Winsock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include "MQMessage.h"
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
//<!message extend class, which was generated on broker;
|
||||
class ROCKETMQCLIENT_API MQMessageExt : public MQMessage {
|
||||
public:
|
||||
MQMessageExt();
|
||||
MQMessageExt(int queueId,
|
||||
int64 bornTimestamp,
|
||||
sockaddr bornHost,
|
||||
int64 storeTimestamp,
|
||||
sockaddr storeHost,
|
||||
std::string msgId);
|
||||
|
||||
virtual ~MQMessageExt();
|
||||
|
||||
static int parseTopicFilterType(int sysFlag);
|
||||
|
||||
int getQueueId() const;
|
||||
void setQueueId(int queueId);
|
||||
|
||||
int64 getBornTimestamp() const;
|
||||
void setBornTimestamp(int64 bornTimestamp);
|
||||
|
||||
sockaddr getBornHost() const;
|
||||
std::string getBornHostString() const;
|
||||
std::string getBornHostNameString() const;
|
||||
void setBornHost(const sockaddr& bornHost);
|
||||
|
||||
int64 getStoreTimestamp() const;
|
||||
void setStoreTimestamp(int64 storeTimestamp);
|
||||
|
||||
sockaddr getStoreHost() const;
|
||||
std::string getStoreHostString() const;
|
||||
void setStoreHost(const sockaddr& storeHost);
|
||||
|
||||
const std::string& getMsgId() const;
|
||||
void setMsgId(const std::string& msgId);
|
||||
|
||||
const std::string& getOffsetMsgId() const;
|
||||
void setOffsetMsgId(const std::string& offsetMsgId);
|
||||
|
||||
int getBodyCRC() const;
|
||||
void setBodyCRC(int bodyCRC);
|
||||
|
||||
int64 getQueueOffset() const;
|
||||
void setQueueOffset(int64 queueOffset);
|
||||
|
||||
int64 getCommitLogOffset() const;
|
||||
void setCommitLogOffset(int64 physicOffset);
|
||||
|
||||
int getStoreSize() const;
|
||||
void setStoreSize(int storeSize);
|
||||
|
||||
int getReconsumeTimes() const;
|
||||
void setReconsumeTimes(int reconsumeTimes);
|
||||
|
||||
int64 getPreparedTransactionOffset() const;
|
||||
void setPreparedTransactionOffset(int64 preparedTransactionOffset);
|
||||
|
||||
std::string toString() const {
|
||||
std::stringstream ss;
|
||||
ss << "MessageExt [queueId=" << m_queueId << ", storeSize=" << m_storeSize << ", queueOffset=" << m_queueOffset
|
||||
<< ", sysFlag=" << m_sysFlag << ", bornTimestamp=" << m_bornTimestamp << ", bornHost=" << getBornHostString()
|
||||
<< ", storeTimestamp=" << m_storeTimestamp << ", storeHost=" << getStoreHostString() << ", msgId=" << m_msgId
|
||||
<< ", commitLogOffset=" << m_commitLogOffset << ", bodyCRC=" << m_bodyCRC
|
||||
<< ", reconsumeTimes=" << m_reconsumeTimes << ", preparedTransactionOffset=" << m_preparedTransactionOffset
|
||||
<< ", " << MQMessage::toString() << "]";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
private:
|
||||
int64 m_queueOffset;
|
||||
int64 m_commitLogOffset;
|
||||
int64 m_bornTimestamp;
|
||||
int64 m_storeTimestamp;
|
||||
int64 m_preparedTransactionOffset;
|
||||
int m_queueId;
|
||||
int m_storeSize;
|
||||
int m_bodyCRC;
|
||||
int m_reconsumeTimes;
|
||||
sockaddr m_bornHost;
|
||||
sockaddr m_storeHost;
|
||||
std::string m_msgId;
|
||||
std::string m_offsetMsgId;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
57
LFtid1056/cloudfront/code/rocketmq/MQMessageListener.h
Normal file
57
LFtid1056/cloudfront/code/rocketmq/MQMessageListener.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __MESSAGELISTENER_H__
|
||||
#define __MESSAGELISTENER_H__
|
||||
|
||||
#include <limits.h>
|
||||
#include "MQMessageExt.h"
|
||||
#include "MQMessageQueue.h"
|
||||
|
||||
namespace rocketmq {
|
||||
//<!***************************************************************************
|
||||
enum ConsumeStatus {
|
||||
// consume success, msg will be cleard from memory
|
||||
CONSUME_SUCCESS,
|
||||
// consume fail, but will be re-consume by call messageLisenter again
|
||||
RECONSUME_LATER
|
||||
};
|
||||
|
||||
enum MessageListenerType { messageListenerDefaultly = 0, messageListenerOrderly = 1, messageListenerConcurrently = 2 };
|
||||
|
||||
class ROCKETMQCLIENT_API MQMessageListener {
|
||||
public:
|
||||
virtual ~MQMessageListener() {}
|
||||
virtual ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& msgs) = 0;
|
||||
virtual MessageListenerType getMessageListenerType() { return messageListenerDefaultly; }
|
||||
};
|
||||
|
||||
class ROCKETMQCLIENT_API MessageListenerOrderly : public MQMessageListener {
|
||||
public:
|
||||
virtual ~MessageListenerOrderly() {}
|
||||
virtual ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& msgs) = 0;
|
||||
virtual MessageListenerType getMessageListenerType() { return messageListenerOrderly; }
|
||||
};
|
||||
|
||||
class ROCKETMQCLIENT_API MessageListenerConcurrently : public MQMessageListener {
|
||||
public:
|
||||
virtual ~MessageListenerConcurrently() {}
|
||||
virtual ConsumeStatus consumeMessage(const std::vector<MQMessageExt>& msgs) = 0;
|
||||
virtual MessageListenerType getMessageListenerType() { return messageListenerConcurrently; }
|
||||
};
|
||||
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
59
LFtid1056/cloudfront/code/rocketmq/MQMessageQueue.h
Normal file
59
LFtid1056/cloudfront/code/rocketmq/MQMessageQueue.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __MQMESSAGEQUEUE_H__
|
||||
#define __MQMESSAGEQUEUE_H__
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class ROCKETMQCLIENT_API MQMessageQueue {
|
||||
public:
|
||||
MQMessageQueue();
|
||||
MQMessageQueue(const std::string& topic, const std::string& brokerName, int queueId);
|
||||
MQMessageQueue(const MQMessageQueue& other);
|
||||
MQMessageQueue& operator=(const MQMessageQueue& other);
|
||||
|
||||
std::string getTopic() const;
|
||||
void setTopic(const std::string& topic);
|
||||
|
||||
std::string getBrokerName() const;
|
||||
void setBrokerName(const std::string& brokerName);
|
||||
|
||||
int getQueueId() const;
|
||||
void setQueueId(int queueId);
|
||||
|
||||
bool operator==(const MQMessageQueue& mq) const;
|
||||
bool operator<(const MQMessageQueue& mq) const;
|
||||
int compareTo(const MQMessageQueue& mq) const;
|
||||
|
||||
const std::string toString() const {
|
||||
std::stringstream ss;
|
||||
ss << "MessageQueue [topic=" << m_topic << ", brokerName=" << m_brokerName << ", queueId=" << m_queueId << "]";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_topic;
|
||||
std::string m_brokerName;
|
||||
int m_queueId;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
30
LFtid1056/cloudfront/code/rocketmq/MQSelector.h
Normal file
30
LFtid1056/cloudfront/code/rocketmq/MQSelector.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef _MQSELECTOR_H_
|
||||
#define _MQSELECTOR_H_
|
||||
#include "MQMessage.h"
|
||||
#include "MQMessageQueue.h"
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class ROCKETMQCLIENT_API MessageQueueSelector {
|
||||
public:
|
||||
virtual ~MessageQueueSelector() {}
|
||||
virtual MQMessageQueue select(const std::vector<MQMessageQueue>& mqs, const MQMessage& msg, void* arg) = 0;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
32
LFtid1056/cloudfront/code/rocketmq/MQueueListener.h
Normal file
32
LFtid1056/cloudfront/code/rocketmq/MQueueListener.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __MESSAGEQUEUELISTENER_H__
|
||||
#define __MESSAGEQUEUELISTENER_H__
|
||||
|
||||
#include <vector>
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class ROCKETMQCLIENT_API MQueueListener {
|
||||
public:
|
||||
virtual ~MQueueListener() {}
|
||||
virtual void messageQueueChanged(const std::string& topic,
|
||||
std::vector<MQMessageQueue>& mqAll,
|
||||
std::vector<MQMessageQueue>& mqDivided) = 0;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
65
LFtid1056/cloudfront/code/rocketmq/PullResult.h
Normal file
65
LFtid1056/cloudfront/code/rocketmq/PullResult.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __PULLRESULT_H__
|
||||
#define __PULLRESULT_H__
|
||||
|
||||
#include <sstream>
|
||||
#include "MQMessageExt.h"
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
enum PullStatus {
|
||||
FOUND,
|
||||
NO_NEW_MSG,
|
||||
NO_MATCHED_MSG,
|
||||
OFFSET_ILLEGAL,
|
||||
BROKER_TIMEOUT // indicate pull request timeout or received NULL response
|
||||
};
|
||||
|
||||
static const char* EnumStrings[] = {"FOUND", "NO_NEW_MSG", "NO_MATCHED_MSG", "OFFSET_ILLEGAL", "BROKER_TIMEOUT"};
|
||||
|
||||
class ROCKETMQCLIENT_API PullResult {
|
||||
public:
|
||||
PullResult();
|
||||
PullResult(PullStatus status);
|
||||
PullResult(PullStatus pullStatus, int64 nextBeginOffset, int64 minOffset, int64 maxOffset);
|
||||
|
||||
PullResult(PullStatus pullStatus,
|
||||
int64 nextBeginOffset,
|
||||
int64 minOffset,
|
||||
int64 maxOffset,
|
||||
const std::vector<MQMessageExt>& src);
|
||||
|
||||
virtual ~PullResult();
|
||||
|
||||
std::string toString() {
|
||||
std::stringstream ss;
|
||||
ss << "PullResult [ pullStatus=" << EnumStrings[pullStatus] << ", nextBeginOffset=" << nextBeginOffset
|
||||
<< ", minOffset=" << minOffset << ", maxOffset=" << maxOffset << ", msgFoundList=" << msgFoundList.size()
|
||||
<< " ]";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
public:
|
||||
PullStatus pullStatus;
|
||||
int64 nextBeginOffset;
|
||||
int64 minOffset;
|
||||
int64 maxOffset;
|
||||
std::vector<MQMessageExt> msgFoundList;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
55
LFtid1056/cloudfront/code/rocketmq/RocketMQClient.h
Normal file
55
LFtid1056/cloudfront/code/rocketmq/RocketMQClient.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __ROCKETMQCLIENT_H__
|
||||
#define __ROCKETMQCLIENT_H__
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef ROCKETMQCLIENT_EXPORTS
|
||||
#ifdef _WINDLL
|
||||
#define ROCKETMQCLIENT_API __declspec(dllexport)
|
||||
#else
|
||||
#define ROCKETMQCLIENT_API
|
||||
#endif
|
||||
#else
|
||||
#ifdef ROCKETMQCLIENT_IMPORT
|
||||
#define ROCKETMQCLIENT_API __declspec(dllimport)
|
||||
#else
|
||||
#define ROCKETMQCLIENT_API
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define ROCKETMQCLIENT_API
|
||||
#endif
|
||||
|
||||
/** A platform-independent 8-bit signed integer type. */
|
||||
typedef signed char int8;
|
||||
/** A platform-independent 8-bit unsigned integer type. */
|
||||
typedef unsigned char uint8;
|
||||
/** A platform-independent 16-bit signed integer type. */
|
||||
typedef signed short int16;
|
||||
/** A platform-independent 16-bit unsigned integer type. */
|
||||
typedef unsigned short uint16;
|
||||
/** A platform-independent 32-bit signed integer type. */
|
||||
typedef signed int int32;
|
||||
/** A platform-independent 32-bit unsigned integer type. */
|
||||
typedef unsigned int uint32;
|
||||
/** A platform-independent 64-bit integer type. */
|
||||
typedef long long int64;
|
||||
/** A platform-independent 64-bit unsigned integer type. */
|
||||
typedef unsigned long long uint64;
|
||||
|
||||
#endif
|
||||
71
LFtid1056/cloudfront/code/rocketmq/SendResult.h
Normal file
71
LFtid1056/cloudfront/code/rocketmq/SendResult.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __SENDRESULT_H__
|
||||
#define __SENDRESULT_H__
|
||||
|
||||
#include "MQMessageQueue.h"
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
|
||||
enum SendStatus { SEND_OK, SEND_FLUSH_DISK_TIMEOUT, SEND_FLUSH_SLAVE_TIMEOUT, SEND_SLAVE_NOT_AVAILABLE };
|
||||
|
||||
class ROCKETMQCLIENT_API SendResult {
|
||||
public:
|
||||
SendResult();
|
||||
SendResult(const SendStatus& sendStatus,
|
||||
const std::string& msgId,
|
||||
const std::string& offsetMsgId,
|
||||
const MQMessageQueue& messageQueue,
|
||||
int64 queueOffset);
|
||||
SendResult(const SendStatus& sendStatus,
|
||||
const std::string& msgId,
|
||||
const std::string& offsetMsgId,
|
||||
const MQMessageQueue& messageQueue,
|
||||
int64 queueOffset,
|
||||
const std::string& regionId);
|
||||
|
||||
virtual ~SendResult();
|
||||
SendResult(const SendResult& other);
|
||||
SendResult& operator=(const SendResult& other);
|
||||
|
||||
void setTransactionId(const std::string& id) { m_transactionId = id; }
|
||||
|
||||
std::string getTransactionId() { return m_transactionId; }
|
||||
|
||||
const std::string& getMsgId() const;
|
||||
const std::string& getOffsetMsgId() const;
|
||||
|
||||
const std::string& getRegionId() const;
|
||||
void setRegionId(const std::string& regionId);
|
||||
SendStatus getSendStatus() const;
|
||||
MQMessageQueue getMessageQueue() const;
|
||||
int64 getQueueOffset() const;
|
||||
std::string toString() const;
|
||||
|
||||
private:
|
||||
SendStatus m_sendStatus;
|
||||
std::string m_msgId;
|
||||
std::string m_offsetMsgId;
|
||||
MQMessageQueue m_messageQueue;
|
||||
int64 m_queueOffset;
|
||||
std::string m_transactionId;
|
||||
std::string m_regionId;
|
||||
};
|
||||
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
73
LFtid1056/cloudfront/code/rocketmq/SessionCredentials.h
Normal file
73
LFtid1056/cloudfront/code/rocketmq/SessionCredentials.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __SESSIONCREDENTIALS_H__
|
||||
#define __SESSIONCREDENTIALS_H__
|
||||
|
||||
#include "RocketMQClient.h"
|
||||
|
||||
namespace rocketmq {
|
||||
|
||||
class SessionCredentials {
|
||||
public:
|
||||
static const std::string AccessKey;
|
||||
static const std::string SecretKey;
|
||||
static const std::string Signature;
|
||||
static const std::string SignatureMethod;
|
||||
static const std::string ONSChannelKey;
|
||||
|
||||
SessionCredentials(std::string input_accessKey, std::string input_secretKey, const std::string& input_authChannel)
|
||||
: accessKey(input_accessKey), secretKey(input_secretKey), authChannel(input_authChannel) {}
|
||||
SessionCredentials() : authChannel("ALIYUN") {}
|
||||
~SessionCredentials() {}
|
||||
|
||||
std::string getAccessKey() const { return accessKey; }
|
||||
|
||||
void setAccessKey(std::string input_accessKey) { accessKey = input_accessKey; }
|
||||
|
||||
std::string getSecretKey() const { return secretKey; }
|
||||
|
||||
void setSecretKey(std::string input_secretKey) { secretKey = input_secretKey; }
|
||||
|
||||
std::string getSignature() const { return signature; }
|
||||
|
||||
void setSignature(std::string input_signature) { signature = input_signature; }
|
||||
|
||||
std::string getSignatureMethod() const { return signatureMethod; }
|
||||
|
||||
void setSignatureMethod(std::string input_signatureMethod) { signatureMethod = input_signatureMethod; }
|
||||
|
||||
std::string getAuthChannel() const { return authChannel; }
|
||||
|
||||
void setAuthChannel(std::string input_channel) { authChannel = input_channel; }
|
||||
|
||||
bool isValid() const {
|
||||
if (accessKey.empty() || secretKey.empty() || authChannel.empty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string accessKey;
|
||||
std::string secretKey;
|
||||
std::string signature;
|
||||
std::string signatureMethod;
|
||||
std::string authChannel;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
48
LFtid1056/cloudfront/code/rocketmq/TransactionListener.h
Normal file
48
LFtid1056/cloudfront/code/rocketmq/TransactionListener.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __TRANSACTIONLISTENER_H__
|
||||
#define __TRANSACTIONLISTENER_H__
|
||||
|
||||
#include "MQMessage.h"
|
||||
#include "MQMessageExt.h"
|
||||
#include "TransactionSendResult.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class ROCKETMQCLIENT_API TransactionListener {
|
||||
public:
|
||||
virtual ~TransactionListener() {}
|
||||
/**
|
||||
* When send transactional prepare(half) message succeed, this method will be invoked to execute local transaction.
|
||||
*
|
||||
* @param msg Half(prepare) message
|
||||
* @param arg Custom business parameter
|
||||
* @return Transaction state
|
||||
*/
|
||||
virtual LocalTransactionState executeLocalTransaction(const MQMessage& msg, void* arg) = 0;
|
||||
|
||||
/**
|
||||
* When no response to prepare(half) message. broker will send check message to check the transaction status, and this
|
||||
* method will be invoked to get local transaction status.
|
||||
*
|
||||
* @param msg Check message
|
||||
* @return Transaction state
|
||||
*/
|
||||
virtual LocalTransactionState checkLocalTransaction(const MQMessageExt& msg) = 0;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
100
LFtid1056/cloudfront/code/rocketmq/TransactionMQProducer.h
Normal file
100
LFtid1056/cloudfront/code/rocketmq/TransactionMQProducer.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __TRANSACTIONMQPRODUCER_H__
|
||||
#define __TRANSACTIONMQPRODUCER_H__
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "MQClient.h"
|
||||
#include "MQMessage.h"
|
||||
#include "MQMessageExt.h"
|
||||
#include "SessionCredentials.h"
|
||||
#include "TransactionListener.h"
|
||||
#include "TransactionSendResult.h"
|
||||
|
||||
namespace rocketmq {
|
||||
class TransactionMQProducerImpl;
|
||||
class ROCKETMQCLIENT_API TransactionMQProducer {
|
||||
public:
|
||||
TransactionMQProducer(const std::string& producerGroup);
|
||||
virtual ~TransactionMQProducer();
|
||||
|
||||
void start();
|
||||
void shutdown();
|
||||
std::string version();
|
||||
|
||||
const std::string& getNamesrvAddr() const;
|
||||
void setNamesrvAddr(const std::string& namesrvAddr);
|
||||
const std::string& getNamesrvDomain() const;
|
||||
void setNamesrvDomain(const std::string& namesrvDomain);
|
||||
const std::string& getInstanceName() const;
|
||||
void setInstanceName(const std::string& instanceName);
|
||||
|
||||
const std::string& getNameSpace() const;
|
||||
void setNameSpace(const std::string& nameSpace);
|
||||
const std::string& getGroupName() const;
|
||||
void setGroupName(const std::string& groupname);
|
||||
void setSessionCredentials(const std::string& accessKey,
|
||||
const std::string& secretKey,
|
||||
const std::string& accessChannel);
|
||||
const SessionCredentials& getSessionCredentials() const;
|
||||
|
||||
void setUnitName(std::string unitName);
|
||||
const std::string& getUnitName() const;
|
||||
|
||||
int getSendMsgTimeout() const;
|
||||
void setSendMsgTimeout(int sendMsgTimeout);
|
||||
void setTcpTransportPullThreadNum(int num);
|
||||
int getTcpTransportPullThreadNum() const;
|
||||
|
||||
void setTcpTransportConnectTimeout(uint64_t timeout); // ms
|
||||
uint64_t getTcpTransportConnectTimeout() const;
|
||||
|
||||
void setTcpTransportTryLockTimeout(uint64_t timeout); // ms
|
||||
uint64_t getTcpTransportTryLockTimeout() const;
|
||||
|
||||
int getCompressMsgBodyOverHowmuch() const;
|
||||
void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch);
|
||||
int getCompressLevel() const;
|
||||
void setCompressLevel(int compressLevel);
|
||||
|
||||
int getMaxMessageSize() const;
|
||||
void setMaxMessageSize(int maxMessageSize);
|
||||
|
||||
void setLogLevel(elogLevel inputLevel);
|
||||
elogLevel getLogLevel();
|
||||
void setLogFileSizeAndNum(int fileNum, long perFileSize); // perFileSize is MB unit
|
||||
void setMessageTrace(bool messageTrace);
|
||||
bool getMessageTrace() const;
|
||||
std::shared_ptr<TransactionListener> getTransactionListener();
|
||||
void setTransactionListener(TransactionListener* listener);
|
||||
TransactionSendResult sendMessageInTransaction(MQMessage& msg, void* arg);
|
||||
void checkTransactionState(const std::string& addr,
|
||||
const MQMessageExt& message,
|
||||
long tranStateTableOffset,
|
||||
long commitLogOffset,
|
||||
const std::string& msgId,
|
||||
const std::string& transactionId,
|
||||
const std::string& offsetMsgId);
|
||||
|
||||
private:
|
||||
TransactionMQProducerImpl* impl;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
|
||||
#endif
|
||||
48
LFtid1056/cloudfront/code/rocketmq/TransactionSendResult.h
Normal file
48
LFtid1056/cloudfront/code/rocketmq/TransactionSendResult.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __TRANSACTIONSENDRESULT_H__
|
||||
#define __TRANSACTIONSENDRESULT_H__
|
||||
|
||||
#include "SendResult.h"
|
||||
|
||||
namespace rocketmq {
|
||||
|
||||
enum LocalTransactionState { COMMIT_MESSAGE, ROLLBACK_MESSAGE, UNKNOWN };
|
||||
|
||||
class ROCKETMQCLIENT_API TransactionSendResult : public SendResult {
|
||||
public:
|
||||
TransactionSendResult() {}
|
||||
|
||||
TransactionSendResult(const SendStatus& sendStatus,
|
||||
const std::string& msgId,
|
||||
const std::string& offsetMsgId,
|
||||
const MQMessageQueue& messageQueue,
|
||||
int64 queueOffset)
|
||||
: SendResult(sendStatus, msgId, offsetMsgId, messageQueue, queueOffset) {}
|
||||
|
||||
LocalTransactionState getLocalTransactionState() { return m_localTransactionState; }
|
||||
|
||||
void setLocalTransactionState(LocalTransactionState localTransactionState) {
|
||||
m_localTransactionState = localTransactionState;
|
||||
}
|
||||
|
||||
private:
|
||||
LocalTransactionState m_localTransactionState;
|
||||
};
|
||||
} // namespace rocketmq
|
||||
#endif
|
||||
Reference in New Issue
Block a user