Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add c interface to set client current language for Python SDK. #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/CProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ ROCKETMQCLIENT_API int SendMessageTransaction(CProducer* producer,
CLocalTransactionExecutorCallback callback,
void* userData,
CSendResult* result);

ROCKETMQCLIENT_API int SetProducerLanguage(CProducer* producer,
const char* language);
#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/CPullConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ ROCKETMQCLIENT_API CPullResult
Pull(CPullConsumer* consumer, const CMessageQueue* mq, const char* subExpression, long long offset, int maxNums);
ROCKETMQCLIENT_API int ReleasePullResult(CPullResult pullResult);

ROCKETMQCLIENT_API int SetPullConsumerLanguage(CPullConsumer* pullConsumer, const char* language);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions include/CPushConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ROCKETMQCLIENT_API int SetPushConsumerMessageModel(CPushConsumer* consumer, CMes
ROCKETMQCLIENT_API int SetPushConsumerMaxCacheMessageSize(CPushConsumer* consumer, int maxCacheSize);
ROCKETMQCLIENT_API int SetPushConsumerMaxCacheMessageSizeInMb(CPushConsumer* consumer, int maxCacheSizeInMb);
ROCKETMQCLIENT_API int SetPushConsumerMessageTrace(CPushConsumer* consumer, CTraceModel openTrace);
ROCKETMQCLIENT_API int SetPushConsumerLanguage(CPushConsumer* consumer, const char* language);

#ifdef __cplusplus
}
Expand Down
4 changes: 4 additions & 0 deletions src/common/MQVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ const char* MQVersion::GetVersionDesc(int value) {
}
return RocketMQCPPClientVersion[currentVersion];
}

const void MQVersion::SetCurrentLanguage(const char* language) {
MQVersion::s_CurrentLanguage = language;
}
//<!***************************************************************************
} // namespace rocketmq
1 change: 1 addition & 0 deletions src/common/MQVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,7 @@ class MQVersion {
};

static const char* GetVersionDesc(int value);
static const void SetCurrentLanguage(const char* language);
static int s_CurrentVersion;
static std::string s_CurrentLanguage;
};
Expand Down
6 changes: 6 additions & 0 deletions src/extern/CProducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "TransactionMQProducer.h"
#include "TransactionSendResult.h"
#include "UtilAll.h"
#include "MQVersion.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -815,6 +816,11 @@ int SetProducerMessageTrace(CProducer* producer, CTraceModel openTrace) {
}
return OK;
}

int SetProducerLanguage(CProducer* producer, const char* language) {
MQVersion::SetCurrentLanguage(language);
return OK;
}
#ifdef __cplusplus
};
#endif
6 changes: 6 additions & 0 deletions src/extern/CPullConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "CMessageExt.h"
#include "DefaultMQPullConsumer.h"
#include "MQClientErrorContainer.h"
#include "MQVersion.h"

using namespace rocketmq;
using namespace std;
Expand Down Expand Up @@ -254,6 +255,11 @@ int ReleasePullResult(CPullResult pullResult) {
return OK;
}

int SetPullConsumerLanguage(CPullConsumer * consumer, const char* language) {
MQVersion::SetCurrentLanguage(language);
return OK;
}

#ifdef __cplusplus
};
#endif
6 changes: 6 additions & 0 deletions src/extern/CPushConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "CMessageExt.h"
#include "DefaultMQPushConsumer.h"
#include "MQClientErrorContainer.h"
#include "MQVersion.h"

using namespace rocketmq;
using namespace std;
Expand Down Expand Up @@ -304,6 +305,11 @@ int SetPushConsumerMessageTrace(CPushConsumer* consumer, CTraceModel openTrace)
((DefaultMQPushConsumer*)consumer)->setMessageTrace(messageTrace);
return OK;
}

int SetPushConsumerLanguage(CPushConsumer * consumer, const char* language) {
MQVersion::SetCurrentLanguage(language);
return OK;
}
#ifdef __cplusplus
};
#endif
3 changes: 2 additions & 1 deletion src/transport/ClientRemotingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "ConsumerRunningInfo.h"
#include "MQClientFactory.h"
#include "UtilAll.h"
#include "MQVersion.h"

namespace rocketmq {

Expand Down Expand Up @@ -111,7 +112,7 @@ RemotingCommand* ClientRemotingProcessor::getConsumerRunningInfo(const string& a
LOG_INFO("getConsumerRunningInfo:%s", requestHeader->getConsumerGroup().c_str());

RemotingCommand* pResponse =
new RemotingCommand(request->getCode(), "CPP", request->getVersion(), request->getOpaque(), request->getFlag(),
new RemotingCommand(request->getCode(), MQVersion::s_CurrentLanguage, request->getVersion(), request->getOpaque(), request->getFlag(),
request->getRemark(), NULL);

unique_ptr<ConsumerRunningInfo> runningInfo(
Expand Down