コード例 #1
0
ファイル: SendReplyService.cs プロジェクト: zoombjm/enode
        private async void SendRemotingRequestAsync(CommandExecutedMessage message, string replyAddress)
        {
            var replyEndpoint = TryParseReplyAddress(replyAddress);

            if (replyEndpoint == null)
            {
                return;
            }

            var json = _jsonSerializer.Serialize(message);
            var data = Encoding.UTF8.GetBytes(json);

            try
            {
                var remotingClient   = CreateReplyRemotingClient(replyEndpoint);
                var remotingRequest  = new RemotingRequest(Constants.SendCommandReplyMessageRequestCode, data);
                var remotingResponse = await remotingClient.InvokeAsync(remotingRequest, 5000);

                if (remotingResponse.Code != Constants.SuccessResponseCode)
                {
                    _logger.ErrorFormat("Send command executed message failed. replyAddress: {0}, message: {1}, responseCode: {2}", replyAddress, messageJson, remotingResponse.Code);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Send command executed message failed. replyAddress: {0}, message: {1}", replyAddress, messageJson), ex);
            }
        }
コード例 #2
0
        public void SendAsync(CommandExecutedMessage message, string topic)
        {
            var messageJson   = _jsonSerializer.Serialize(message);
            var messageBytes  = Encoding.UTF8.GetBytes(messageJson);
            var equeueMessage = new EQueueMessage(topic, (int)EQueueMessageTypeCode.CommandExecutedMessage, messageBytes);

            SendMessageAsync(equeueMessage, messageJson, message.CommandId, 0);
        }
コード例 #3
0
            public void OnCommandExecuted(CommandResult commandResult)
            {
                _messageContext.OnMessageHandled(_queueMessage);

                if (string.IsNullOrEmpty(_commandMessage.ReplyAddress))
                {
                    return;
                }

                var message = new CommandExecutedMessage
                {
                    CommandId         = commandResult.CommandId,
                    AggregateRootId   = commandResult.AggregateRootId,
                    CommandStatus     = commandResult.Status,
                    ExceptionTypeName = commandResult.ExceptionTypeName,
                    ErrorMessage      = commandResult.ErrorMessage,
                };

                _sendReplyService.SendReply((int)CommandReplyType.CommandExecuted, message, _commandMessage.ReplyAddress);
            }
コード例 #4
0
ファイル: SendReplyService.cs プロジェクト: ivivisoft/enode
        private async void SendRemotingRequestAsync(CommandExecutedMessage message, string replyAddress)
        {
            var replyEndpoint = TryParseReplyAddress(replyAddress);
            if (replyEndpoint == null) return;

            var json = _jsonSerializer.Serialize(message);
            var data = Encoding.UTF8.GetBytes(json);
            try
            {
                var remotingClient = CreateReplyRemotingClient(replyEndpoint);
                var remotingRequest = new RemotingRequest(Constants.SendCommandReplyMessageRequestCode, data);
                var remotingResponse = await remotingClient.InvokeAsync(remotingRequest, 5000);
                if (remotingResponse.Code != Constants.SuccessResponseCode)
                {
                    _logger.ErrorFormat("Send command executed message failed. replyAddress: {0}, message: {1}, responseCode: {2}", replyAddress, messageJson, remotingResponse.Code);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Send command executed message failed. replyAddress: {0}, message: {1}", replyAddress, messageJson), ex);
            }
        }
コード例 #5
0
ファイル: SendReplyService.cs プロジェクト: zoombjm/enode
 public void SendCommandReplyMessageRequestAsync(CommandExecutedMessage message, string replyAddress)
 {
 }
コード例 #6
0
ファイル: SendReplyService.cs プロジェクト: ivivisoft/enode
        public void SendCommandReplyMessageRequestAsync(CommandExecutedMessage message, string replyAddress)
        {

        }
コード例 #7
0
 public void Send(CommandExecutedMessage message, string topic)
 {
     _producer.SendAsync(new Message(topic, _binarySerializer.Serialize(message)), message.AggregateRootId);
 }