protected override void ConsumeMessage(IMessageReply reply) { base.ConsumeMessage(reply); if (_isDistributor) { _commandDistributor.EnqueueMessage(new MessageHandledNotification(reply.MessageID).GetFrame()); } }
protected override void ConsumeMessage(IMessageReply reply) { base.ConsumeMessage(reply); if (_isDistributor) { _commandDistributor.EnqueueMessage(new MessageHandledNotification(reply.MessageID).GetFrame()); } }
protected void ConsumeReply(IMessageReply reply) { _logger.InfoFormat("Handle reply:{0} content:{1}", reply.MessageID, reply.ToJson()); var messageState = _commandStateQueues[reply.MessageID] as IFramework.Message.MessageState; if (messageState != null) { _commandStateQueues.TryRemove(reply.MessageID); if (reply.Result is Exception) { messageState.TaskCompletionSource.TrySetException(reply.Result as Exception); } else { messageState.TaskCompletionSource.TrySetResult(reply.Result); } } }
void OnMessageHandled(IFramework.Message.IMessageContext messageContext, IMessageReply reply) { if (!string.IsNullOrWhiteSpace(messageContext.ReplyToEndPoint)) { var messageBody = reply.GetMessageBytes(); Producer.SendAsync(new global::EQueue.Protocols.Message(messageContext.ReplyToEndPoint, messageBody), string.Empty) .ContinueWith(task => { if (task.Result.SendStatus == EQueueClientsProducers.SendStatus.Success) { _Logger.DebugFormat("send reply, commandID:{0}", reply.MessageID); } else { _Logger.ErrorFormat("Send Reply {0}", task.Result.SendStatus.ToString()); } }); } }
protected override void OnMessageHandled(IMessageContext messageContext, IMessageReply reply) { if (!string.IsNullOrWhiteSpace(messageContext.ReplyToEndPoint)) { var replySender = GetReplySender(messageContext.ReplyToEndPoint); if (replySender != null) { replySender.SendFrame(reply.GetFrame()); _Logger.InfoFormat("send reply, commandID:{0}", reply.MessageID); } } if (!string.IsNullOrWhiteSpace(messageContext.FromEndPoint)) { var notificationSender = GetReplySender(messageContext.FromEndPoint); if (notificationSender != null) { notificationSender.SendFrame(new MessageHandledNotification(messageContext.MessageID) .GetFrame()); _Logger.InfoFormat("send notification, commandID:{0}", messageContext.MessageID); } } }
public EchoTextExtension(IMessageReply <TextMessage> messageReply) { _messageReply = messageReply; }
protected override void OnMessageHandled(IMessageContext messageContext, IMessageReply reply) { if (!string.IsNullOrWhiteSpace(messageContext.ReplyToEndPoint)) { var replySender = GetReplySender(messageContext.ReplyToEndPoint); if (replySender != null) { replySender.SendFrame(reply.GetFrame()); _Logger.InfoFormat("send reply, commandID:{0}", reply.MessageID); } } if (!string.IsNullOrWhiteSpace(messageContext.FromEndPoint)) { var notificationSender = GetReplySender(messageContext.FromEndPoint); if (notificationSender != null) { notificationSender.SendFrame(new MessageHandledNotification(messageContext.MessageID) .GetFrame()); _Logger.InfoFormat("send notification, commandID:{0}", messageContext.MessageID); } } }
public static Frame GetFrame(this IMessageReply message) { return(message.GetFrame((short)MessageCode.MessageReply)); }
protected virtual void ConsumeMessage(IMessageContext commandContext) { var command = commandContext.Message as ICommand; IMessageReply messageReply = null; if (command == null) { return; } var needRetry = command.NeedRetry; PerMessageContextLifetimeManager.CurrentMessageContext = commandContext; IEnumerable <IMessageContext> eventContexts = null; var messageStore = IoCFactory.Resolve <IMessageStore>(); var eventBus = IoCFactory.Resolve <IEventBus>(); var commandHasHandled = messageStore.HasCommandHandled(commandContext.MessageID); if (commandHasHandled) { messageReply = NewReply(commandContext.MessageID, new MessageDuplicatelyHandled()); //new MessageReply(commandContext.MessageID, new MessageDuplicatelyHandled()); } else { var messageHandler = _handlerProvider.GetHandler(command.GetType()); _logger.InfoFormat("Handle command, commandID:{0}", commandContext.MessageID); if (messageHandler == null) { messageReply = NewReply(commandContext.MessageID, new NoHandlerExists()); } else { bool success = false; do { try { using (var transactionScope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted })) { ((dynamic)messageHandler).Handle((dynamic)command); messageReply = NewReply(commandContext.MessageID, commandContext.Reply); eventContexts = messageStore.SaveCommand(commandContext, eventBus.GetMessages()); transactionScope.Complete(); } needRetry = false; success = true; } catch (Exception e) { if (e is OptimisticConcurrencyException && needRetry) { eventContexts = null; eventBus.ClearMessages(); } else { messageReply = NewReply(commandContext.MessageID, e.GetBaseException()); if (e is DomainException) { _logger.Warn(command.ToJson(), e); } else { _logger.Error(command.ToJson(), e); } messageStore.SaveFailedCommand(commandContext, e); needRetry = false; } } } while (needRetry); if (success && eventContexts != null && eventContexts.Count() > 0) { IoCFactory.Resolve <IEventPublisher>().Publish(eventContexts.ToArray()); } } } OnMessageHandled(commandContext, messageReply); }
protected abstract void OnMessageHandled(IMessageContext messageContext, IMessageReply reply);
public EchoTextHandler(IMessageReply <TextMessage> messageReply) { _messageReply = messageReply; }
protected abstract void OnMessageHandled(IMessageContext messageContext, IMessageReply reply);
public ClickEventReplyTextExtension(IMessageReply <TextMessage> messageReply) { _messageReply = messageReply; }
public ClickEventReplyTextHandler(IMessageReply <TextMessage> messageReply) { _messageReply = messageReply; }