You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/10/14 14:45:06 UTC

[GitHub] [rocketmq-client-python] duhenglucky commented on a change in pull request #51: Add transaction message support

duhenglucky commented on a change in pull request #51: Add transaction message support
URL: https://github.com/apache/rocketmq-client-python/pull/51#discussion_r334518107
 
 

 ##########
 File path: src/PythonWrapper.cpp
 ##########
 @@ -219,47 +229,58 @@ void PySendExceptionCallback(CMQException e, CMessage *msg, void *pyCallback){
     delete pyCallback;
 }
 
-int PySendMessageAsync(void *producer, void *msg, PyObject *sendSuccessCallback, PyObject *sendExceptionCallback){
-    PyCallback* pyCallback = new PyCallback();
+int PySendMessageAsync(void *producer, void *msg, PyObject *sendSuccessCallback, PyObject *sendExceptionCallback) {
+    PyCallback *pyCallback = new PyCallback();
     pyCallback->successCallback = sendSuccessCallback;
     pyCallback->exceptionCallback = sendExceptionCallback;
-    return SendAsync((CProducer *) producer,  (CMessage *) msg, &PySendSuccessCallback, &PySendExceptionCallback, (void *)pyCallback);
+    return SendAsync((CProducer *) producer, (CMessage *) msg, &PySendSuccessCallback, &PySendExceptionCallback,
+                     (void *) pyCallback);
 }
 
-PySendResult PySendBatchMessage(void *producer, void *batchMessage) {
+
+PySendResult PySendMessageOrderly(void *producer, void *msg, int autoRetryTimes, void *args, PyObject *queueSelector) {
     PySendResult ret;
     CSendResult result;
-    SendBatchMessage((CProducer *) producer, (CBatchMessage *) batchMessage, &result);
+    PyUserData userData = {queueSelector, args};
+    SendMessageOrderly((CProducer *) producer, (CMessage *) msg, &PyOrderlyCallbackInner, &userData, autoRetryTimes,
+                       &result);
     ret.sendStatus = result.sendStatus;
     ret.offset = result.offset;
     strncpy(ret.msgId, result.msgId, MAX_MESSAGE_ID_LENGTH - 1);
     ret.msgId[MAX_MESSAGE_ID_LENGTH - 1] = 0;
     return ret;
 }
 
+int PyOrderlyCallbackInner(int size, CMessage *msg, void *args) {
+    PyUserData *userData = (PyUserData *) args;
+    int index = boost::python::call<int>(userData->pyObject, size, (void *) msg, userData->pData);
+    return index;
+}
 
-PySendResult PySendMessageOrderly(void *producer, void *msg, int autoRetryTimes, void *args, PyObject *queueSelector) {
+PySendResult PySendMessageOrderlyByShardingKey(void *producer, void *msg, const char *shardingKey) {
     PySendResult ret;
     CSendResult result;
-    PyUserData userData = {queueSelector,args};
-    SendMessageOrderly((CProducer *) producer, (CMessage *) msg, &PyOrderlyCallbackInner, &userData, autoRetryTimes, &result);
+    SendMessageOrderlyByShardingKey((CProducer *) producer, (CMessage *) msg, shardingKey, &result);
     ret.sendStatus = result.sendStatus;
     ret.offset = result.offset;
     strncpy(ret.msgId, result.msgId, MAX_MESSAGE_ID_LENGTH - 1);
     ret.msgId[MAX_MESSAGE_ID_LENGTH - 1] = 0;
     return ret;
 }
 
-int PyOrderlyCallbackInner(int size, CMessage *msg, void *args) {
-    PyUserData *userData = (PyUserData *)args;
-    int index = boost::python::call<int>(userData->pyObject, size, (void *) msg, userData->pData);
-    return index;
+CTransactionStatus PyLocalTransactionExecuteCallback(CProducer *producer, CMessage *msg, void *data) {
+    PyUserData *localCallback = (PyUserData *) data;
+    CTransactionStatus status = boost::python::call<CTransactionStatus>(localCallback->pyObject, (void *) msg,
+                                                                        localCallback->pData);
+    return status;
 }
 
-PySendResult PySendMessageOrderlyByShardingKey(void *producer, void *msg, const char *shardingKey) {
+PySendResult PySendMessageInTransaction(void *producer, void *msg, PyObject *localTransactionCallback, void *args) {
+    PyUserData userData = {localTransactionCallback, args};
     PySendResult ret;
     CSendResult result;
-    SendMessageOrderlyByShardingKey((CProducer *) producer, (CMessage *) msg, shardingKey, &result);
+    SendMessageTransaction((CProducer *) producer, (CMessage *) msg, &PyLocalTransactionExecuteCallback, &userData,
 
 Review comment:
   Relative c exporter hasn't released and it will be published ASAP, you can ignore this for now.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services