Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
 public void SendCommandReplyMessageRequestAsync(CommandExecutedMessage message, string replyAddress)
 {
 }
Exemplo n.º 6
0
        public void SendCommandReplyMessageRequestAsync(CommandExecutedMessage message, string replyAddress)
        {

        }
 public void Send(CommandExecutedMessage message, string topic)
 {
     _producer.SendAsync(new Message(topic, _binarySerializer.Serialize(message)), message.AggregateRootId);
 }