internal void OnDispatcherRejectMessage(Message message, Message.RejectionTypes rejectionType, string reason, Exception exception) { if (this.IsEnabled(DispatcherRejectedMessageEventName)) { this.Write(DispatcherRejectedMessageEventName, new { Message = message, RejectionType = rejectionType, Reason = reason, Exception = exception }); } MessagingStatisticsGroup.OnRejectedMessage(message); if (this.IsEnabled(LogLevel.Debug)) { LogDispatcherRejectedMessage(this, message, reason, rejectionType, exception); } }
public void RejectMessage( Message message, Message.RejectionTypes rejectType, Exception exc, string rejectInfo = null) { if (message.Direction == Message.Directions.Request) { var str = String.Format("{0} {1}", rejectInfo ?? "", exc == null ? "" : exc.ToString()); MessagingStatisticsGroup.OnRejectedMessage(message); Message rejection = message.CreateRejectionResponse(rejectType, str); SendRejectionMessage(rejection); } else { logger.Warn(ErrorCode.Messaging_Dispatcher_DiscardRejection, "Discarding {0} rejection for message {1}. Exc = {2}", Enum.GetName(typeof(Message.Directions), message.Direction), message, exc.Message); } }
public void ReceiveMessage(Message msg) { this.messagingTrace.OnIncomingMessageAgentReceiveMessage(msg); // Find the activation it targets; first check for a system activation, then an app activation if (msg.TargetGrain.IsSystemTarget()) { SystemTarget target = this.activationDirectory.FindSystemTarget(msg.TargetActivation); if (target == null) { MessagingStatisticsGroup.OnRejectedMessage(msg); Message response = this.messageFactory.CreateRejectionResponse(msg, Message.RejectionTypes.Unrecoverable, string.Format("SystemTarget {0} not active on this silo. Msg={1}", msg.TargetGrain, msg)); this.messageCenter.SendMessage(response); this.logger.LogWarning( (int)ErrorCode.MessagingMessageFromUnknownActivation, "Received a message {Message} for an unknown SystemTarget: {Target}", msg, msg.TargetAddress); return; } target.ReceiveMessage(msg); } else if (messageCenter.TryDeliverToProxy(msg)) { return; } else { try { var targetActivation = catalog.GetOrCreateActivation( msg.TargetAddress, msg.IsNewPlacement, msg.RequestContextData); if (targetActivation is null) { // Activation does not exists and is not a new placement. if (msg.Direction == Message.Directions.Response) { logger.LogWarning( (int)ErrorCode.Dispatcher_NoTargetActivation, "No target activation {Activation} for response message: {Message}", msg.TargetActivation, msg); return; } else { logger.LogInformation( (int)ErrorCode.Dispatcher_Intermediate_GetOrCreateActivation, "Intermediate NonExistentActivation for message {Message}", msg); var nonExistentActivation = msg.TargetAddress; ProcessRequestToInvalidActivation(msg, nonExistentActivation, null, "Non-existent activation"); return; } } targetActivation.ReceiveMessage(msg); } catch (Exception ex) { MessagingProcessingStatisticsGroup.OnDispatcherMessageProcessedError(msg); logger.LogError( (int)ErrorCode.Dispatcher_ErrorCreatingActivation, ex, "Error creating activation for grain {TargetGrain} (interface: {InterfaceType}). Message {Message}", msg.TargetGrain, msg.InterfaceType, msg); this.RejectMessage(msg, Message.RejectionTypes.Transient, ex); } } }