public async Task <AsyncTaskResult> AddRecordAsync(ThreeMessageHandleRecord record) { try { using (var connection = GetConnection()) { await connection.InsertToMySqlAsync(record, _threeMessageTableName); return(AsyncTaskResult.Success); } } catch (DbException ex) { //if (ex.Number == 2627 && ex.Message.Contains(_threeMessageTablePrimaryKeyName)) //{ // return AsyncTaskResult.Success; //} _logger.Error("Insert three-message handle record has sql exception.", ex); return(new AsyncTaskResult(AsyncTaskStatus.IOException, ex.Message)); } catch (Exception ex) { _logger.Error("Insert three-message handle record has unknown exception.", ex); return(new AsyncTaskResult(AsyncTaskStatus.Failed, ex.Message)); } }
private void HandleThreeMessageAsync(MultiMessageDisptaching multiMessageDispatching, IMessageHandlerProxy3 handlerProxy, string handlerTypeName, QueuedHandler <IMessageHandlerProxy3> queueHandler, int retryTimes) { var messages = multiMessageDispatching.Messages; var message1 = messages[0]; var message2 = messages[1]; var message3 = messages[2]; _ioHelper.TryAsyncActionRecursively <AsyncTaskResult>("HandleTwoMessageAsync", () => handlerProxy.HandleAsync(message1, message2, message3), currentRetryTimes => HandleThreeMessageAsync(multiMessageDispatching, handlerProxy, handlerTypeName, queueHandler, currentRetryTimes), result => { var message1TypeName = _typeNameProvider.GetTypeName(message1.GetType()); var message2TypeName = _typeNameProvider.GetTypeName(message2.GetType()); var message3TypeName = _typeNameProvider.GetTypeName(message3.GetType()); var messageHandleRecord = new ThreeMessageHandleRecord { MessageId1 = message1.Id, MessageId2 = message2.Id, MessageId3 = message3.Id, Message1TypeName = message1TypeName, Message2TypeName = message2TypeName, Message3TypeName = message3TypeName, HandlerTypeName = handlerTypeName, CreatedOn = DateTime.Now }; var sequenceMessage = message1 as ISequenceMessage; if (sequenceMessage != null) { messageHandleRecord.AggregateRootTypeName = sequenceMessage.AggregateRootTypeName; messageHandleRecord.AggregateRootId = sequenceMessage.AggregateRootStringId; messageHandleRecord.Version = sequenceMessage.Version; } AddThreeMessageHandledRecordAsync(multiMessageDispatching, messageHandleRecord, handlerTypeName, handlerProxy, queueHandler, 0); }, () => string.Format("[messages:[{0}], handlerType:{1}]", string.Join("|", messages.Select(x => string.Format("id:{0},type:{1}", x.Id, x.GetType().Name))), handlerProxy.GetInnerObject().GetType().Name), null, retryTimes, true); }
public async Task<AsyncTaskResult> AddRecordAsync(ThreeMessageHandleRecord record) { try { using (var connection = GetConnection()) { await connection.InsertAsync(record, _threeMessageTableName); return AsyncTaskResult.Success; } } catch (SqlException ex) { if (ex.Number == 2627 && ex.Message.Contains(_threeMessageTablePrimaryKeyName)) { return AsyncTaskResult.Success; } _logger.Error("Insert three-message handle record has sql exception.", ex); return new AsyncTaskResult(AsyncTaskStatus.IOException, ex.Message); } catch (Exception ex) { _logger.Error("Insert three-message handle record has unknown exception.", ex); return new AsyncTaskResult(AsyncTaskStatus.Failed, ex.Message); } }
public Task<AsyncTaskResult> AddRecordAsync(ThreeMessageHandleRecord record) { _dict.TryAdd(record.MessageId1 + record.MessageId2 + record.MessageId3 + record.HandlerTypeCode.ToString(), 0); return _successTask; }
private void AddThreeMessageHandledRecordAsync(MultiMessageDisptaching multiMessageDispatching, ThreeMessageHandleRecord messageHandleRecord, string handlerTypeName, IMessageHandlerProxy3 handlerProxy, QueuedHandler <IMessageHandlerProxy3> queueHandler, int retryTimes) { var messages = multiMessageDispatching.Messages; _ioHelper.TryAsyncActionRecursively <AsyncTaskResult>("AddThreeMessageHandledRecordAsync", () => _messageHandleRecordStore.AddRecordAsync(messageHandleRecord), currentRetryTimes => AddThreeMessageHandledRecordAsync(multiMessageDispatching, messageHandleRecord, handlerTypeName, handlerProxy, queueHandler, currentRetryTimes), result => { multiMessageDispatching.RemoveHandledHandler(handlerTypeName); if (queueHandler != null) { queueHandler.OnHandlerFinished(handlerProxy); } if (_logger.IsDebugEnabled) { _logger.DebugFormat("ThreeMessage handled success, [messages:[{0}], handlerType:{1}]", string.Join("|", messages.Select(x => string.Format("id:{0},type:{1}", x.Id, x.GetType().Name))), handlerProxy.GetInnerObject().GetType().Name); } }, () => string.Format("[messages:[{0}], handlerType:{1}]", string.Join("|", messages.Select(x => string.Format("id:{0},type:{1}", x.Id, x.GetType().Name))), handlerProxy.GetInnerObject().GetType().Name), null, retryTimes, true); }
public Task <AsyncTaskResult> AddRecordAsync(ThreeMessageHandleRecord record) { _dict.TryAdd(record.MessageId1 + record.MessageId2 + record.MessageId3 + record.HandlerTypeCode.ToString(), 0); return(_successTask); }