Skip to content
Merged
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
11 changes: 10 additions & 1 deletion rocketmq/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from .ffi import (
dll, _CSendResult, MSG_CALLBACK_FUNC, MessageModel, TRANSACTION_CHECK_CALLBACK,
LOCAL_TRANSACTION_EXECUTE_CALLBACK
LOCAL_TRANSACTION_EXECUTE_CALLBACK, TraceModel
)
from .exceptions import (
ffi_check, NullPointerException,
Expand Down Expand Up @@ -259,6 +259,9 @@ def set_compress_level(self, level):
def set_max_message_size(self, max_size):
ffi_check(dll.SetProducerMaxMessageSize(self._handle, max_size))

def set_message_trace(self, message_trace):
ffi_check(dll.SetProducerMessageTrace(self._handle, message_trace and TraceModel.OPEN or TraceModel.CLOSE))

def start(self):
ffi_check(dll.StartProducer(self._handle))

Expand Down Expand Up @@ -311,6 +314,9 @@ def __exit__(self, exec_type, value, traceback):
def set_name_server_address(self, addr):
ffi_check(dll.SetProducerNameServerAddress(self._handle, _to_bytes(addr)))

def set_message_trace(self, message_trace):
ffi_check(dll.SetProducerMessageTrace(self._handle, message_trace and TraceModel.OPEN or TraceModel.CLOSE))

def start(self):
ffi_check(dll.StartProducer(self._handle))

Expand Down Expand Up @@ -437,3 +443,6 @@ def set_message_batch_max_size(self, max_size):

def set_instance_name(self, name):
ffi_check(dll.SetPushConsumerInstanceName(self._handle, _to_bytes(name)))

def set_message_trace(self, message_trace):
ffi_check(dll.SetPushConsumerMessageTrace(self._handle, message_trace and TraceModel.OPEN or TraceModel.CLOSE))
10 changes: 10 additions & 0 deletions rocketmq/ffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class MessageModel(CtypesEnum):
CLUSTERING = 1


class TraceModel(CtypesEnum):
OPEN = 0
CLOSE = 1


class _CSendResult(Structure):
_fields_ = [
('sendStatus', c_int),
Expand Down Expand Up @@ -200,6 +205,8 @@ class _CMQException(Structure):
dll.SetProducerCompressLevel.restype = _CStatus
dll.SetProducerMaxMessageSize.argtypes = [c_void_p, c_int]
dll.SetProducerMaxMessageSize.restype = _CStatus
dll.SetProducerMessageTrace.argtypes = [c_void_p, TraceModel]
dll.SetProducerMessageTrace.restype = _CStatus
dll.SendMessageSync.argtypes = [c_void_p, c_void_p, POINTER(_CSendResult)]
dll.SendMessageSync.restype = _CStatus
dll.SendMessageOneway.argtypes = [c_void_p, c_void_p]
Expand Down Expand Up @@ -261,6 +268,9 @@ class _CMQException(Structure):
dll.SetPushConsumerLogLevel.restype = _CStatus
dll.SetPushConsumerMessageModel.argtypes = [c_void_p, MessageModel]
dll.SetPushConsumerMessageModel.restype = _CStatus
dll.SetPushConsumerLogLevel.restype = _CStatus
dll.SetPushConsumerMessageTrace.argtypes = [c_void_p, TraceModel]
dll.SetPushConsumerMessageTrace.restype = _CStatus

# Misc
dll.GetLatestErrorMessage.argtypes = []
Expand Down