static void Main(string[] args) { Console.Title = "PushConsumer"; Task.Run(() => { Console.WriteLine("start push consumer..."); var consumerPtr = PushConsumerWrap.CreatePushConsumer("xxx"); var p = new Program(); var consumer = new HandleRef(p, consumerPtr); Console.WriteLine($"consumer: {consumer}"); var r0 = PushConsumerWrap.SetPushConsumerLogLevel(consumer, CLogLevel.E_LOG_LEVEL_TRACE); var groupId = PushConsumerWrap.GetPushConsumerGroupID(consumer.Handle); Console.WriteLine($"groupId: {groupId}"); var r1 = PushConsumerWrap.SetPushConsumerNameServerAddress(consumer, "47.101.55.250:9876"); var r2 = PushConsumerWrap.Subscribe(consumer, "test", "*"); var r3 = PushConsumerWrap.RegisterMessageCallback(consumer, _callback); var r10 = PushConsumerWrap.StartPushConsumer(consumer); Console.WriteLine($"start push consumer ptr: {r10}"); while (true) { Thread.Sleep(500); } }); Console.ReadKey(true); //PushConsumerBinder.DestroyPushConsumer(consumer); }
public void Dispose() { if (this._handleRef.Handle != IntPtr.Zero) { PushConsumerWrap.DestroyPushConsumer(this._handleRef); this._handleRef = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } }
public IPushConsumerBuilder SetPushConsumerMessageModel(MessageModel messageModel) { var result = PushConsumerWrap.SetPushConsumerMessageModel(this._handleRef, (CMessageModel)messageModel); if (result != 0) { throw new RocketMQConsumerException($"set consumer logFileNumAndSize error. cpp sdk return code {result}"); } return(this); }
public bool RegisterMessageCallback(PushConsumerWrap.MessageCallBack callBack) { if (callBack == null) { return(false); } var registerCallbackResult = PushConsumerWrap.RegisterMessageCallback(this._handleRef, callBack); return(registerCallbackResult == 0); }
public bool ShutdownPushConsumer() { if (this._handleRef.Handle == IntPtr.Zero) { return(false); } var shutdownResult = PushConsumerWrap.ShutdownPushConsumer(this._handleRef); return(shutdownResult == 0); }
public bool DestroyPushConsumer() { if (this._handleRef.Handle == IntPtr.Zero) { return(false); } var destroyResult = PushConsumerWrap.DestroyPushConsumer(this._handleRef); return(destroyResult == 0); }
public IPushConsumerBuilder SetPushConsumerLogLevel(LogLevel logLevel) { if (logLevel == LogLevel.None) { throw new ArgumentException(nameof(logLevel)); } var result = PushConsumerWrap.SetPushConsumerLogLevel(this._handleRef, (CLogLevel)logLevel); if (result != 0) { throw new RocketMQConsumerException($"set consumer logLevel error. cpp sdk return code {result}"); } return(this); }
public IPushConsumerBuilder SetPushConsumerLogPath(string logPath) { if (string.IsNullOrWhiteSpace(logPath)) { throw new ArgumentNullException(nameof(logPath)); } var result = PushConsumerWrap.SetPushConsumerLogPath(this._handleRef, logPath); if (result != 0) { throw new RocketMQConsumerException($"set consumer logPath error. cpp sdk return code {result}"); } return(this); }
public IPushConsumerBuilder SetPushConsumerInstanceName(string instanceName) { if (string.IsNullOrWhiteSpace(instanceName)) { throw new ArgumentNullException(nameof(instanceName)); } var result = PushConsumerWrap.SetPushConsumerInstanceName(this._handleRef, instanceName); if (result != 0) { throw new RocketMQConsumerException($"set consumer instanceName error. cpp sdk return code {result}"); } return(this); }
public IPushConsumerBuilder SetPushConsumerGroupId(string groupId) { if (string.IsNullOrWhiteSpace(groupId)) { throw new ArgumentNullException(nameof(groupId)); } var result = PushConsumerWrap.SetPushConsumerGroupID(this._handleRef, groupId); if (result != 0) { throw new RocketMQConsumerException($"set consumer groupId error. cpp sdk return code {result}"); } return(this); }
public IPushConsumerBuilder SetPushConsumerThreadCount(int threadCount) { if (threadCount <= 0) { throw new ArgumentOutOfRangeException(nameof(threadCount)); } var result = PushConsumerWrap.SetPushConsumerThreadCount(this._handleRef, threadCount); if (result != 0) { throw new RocketMQConsumerException($"set consumer threadCount error. cpp sdk return code {result}"); } return(this); }
public void SetPushConsumerNameServerAddress(string nameServerAddress) { if (string.IsNullOrWhiteSpace(nameServerAddress)) { throw new ArgumentNullException(nameof(nameServerAddress)); } var result = PushConsumerWrap.SetPushConsumerNameServerAddress(this._handleRef, nameServerAddress); if (result != 0) { throw new RocketMQConsumerException($"set consumer nameServerAddress error. cpp sdk return code {result}"); } return; }
public IPushConsumerBuilder SetPushConsumerNameServerDomain(string domain) { if (string.IsNullOrWhiteSpace(domain)) { throw new ArgumentNullException(nameof(domain)); } var result = PushConsumerWrap.SetPushConsumerNameServerDomain(this._handleRef, domain); if (result != 0) { throw new RocketMQConsumerException($"set consumer domain error. cpp sdk return code {result}"); } return(this); }
public IPushConsumerBuilder SetPushConsumerMessageBatchMaxSize(int batchSize) { if (batchSize <= 0) { throw new ArgumentOutOfRangeException(nameof(batchSize)); } var result = PushConsumerWrap.SetPushConsumerMessageBatchMaxSize(this._handleRef, batchSize); if (result != 0) { throw new RocketMQConsumerException($"set consumer batchSize error. cpp sdk return code {result}"); } return(this); }
public DefaultPushConsumerBuilder(string groupId) { if (string.IsNullOrWhiteSpace(groupId)) { throw new ArgumentNullException(nameof(groupId)); } var handle = PushConsumerWrap.CreatePushConsumer(groupId); if (handle == IntPtr.Zero) { throw new RocketMQConsumerException($"create consumer error, ptr is {handle}"); } this._handleRef = new HandleRef(this, handle); }
private void MQPushConsumerInit(string groupId) { if (string.IsNullOrWhiteSpace(groupId)) { throw new ArgumentNullException(nameof(groupId)); } var handle = PushConsumerWrap.CreatePushConsumer(groupId); if (handle == IntPtr.Zero) { throw new RocketMQConsumerException($"create consumer error, ptr is {handle}"); } this._handleRef = new HandleRef(this, handle); this.SetPushConsumerLogPath(this.LogPath); }
public void Subscribe(string topic, string expression) { if (string.IsNullOrWhiteSpace(topic)) { throw new ArgumentNullException(nameof(topic)); } if (string.IsNullOrWhiteSpace(expression)) { throw new ArgumentNullException(nameof(expression)); } var result = PushConsumerWrap.Subscribe(this._handleRef, topic, expression); if (result != 0) { throw new RocketMQConsumerException($"push consumer subscribe error. cpp sdk return code: {result}"); } }
public IPushConsumerBuilder SetPushConsumerLogFileNumAndSize(int fileNum, long fileSize) { if (fileNum <= 0) { throw new ArgumentOutOfRangeException(nameof(fileNum)); } if (fileSize <= 0) { throw new ArgumentOutOfRangeException(nameof(fileSize)); } var result = PushConsumerWrap.SetPushConsumerLogFileNumAndSize(this._handleRef, fileNum, fileSize); if (result != 0) { throw new RocketMQConsumerException($"set consumer logFileNumAndSize error. cpp sdk return code {result}"); } return(this); }
public IPushConsumerBuilder SetPushConsumerSessionCredentials(string accessKey, string secretKey, string channel) { if (string.IsNullOrWhiteSpace(accessKey)) { throw new ArgumentNullException(nameof(accessKey)); } if (string.IsNullOrWhiteSpace(secretKey)) { throw new ArgumentNullException(nameof(secretKey)); } if (string.IsNullOrWhiteSpace(channel)) { throw new ArgumentNullException(nameof(channel)); } var result = PushConsumerWrap.SetPushConsumerSessionCredentials(this._handleRef, accessKey, secretKey, channel); if (result != 0) { throw new RocketMQConsumerException($"set consumer sessionCredentials error. cpp sdk return code {result}"); } return(this); }
public bool StartPushConsumer() { var startResult = PushConsumerWrap.StartPushConsumer(this._handleRef); return(startResult == 0); }
public string GetPushConsumerGroupID() { return(PushConsumerWrap.GetPushConsumerGroupID(this._handleRef.Handle)); }