Exemple #1
0
        static void ValidateMessageSize(IRoutingMessage messageToBeValidated)
        {
            long messageSize = messageToBeValidated.Size();

            if (messageSize > MaxMessageSize)
            {
                throw new EdgeHubMessageTooLargeException($"Message size is {messageSize} bytes which is greater than the max size {MaxMessageSize} bytes allowed");
            }
        }
Exemple #2
0
        static void ValidateMessageSize(IRoutingMessage messageToBeValidated)
        {
            long messageSize = messageToBeValidated.Size();

            if (messageSize > MaxMessageSize)
            {
                throw new InvalidOperationException($"Message size exceeds maximum allowed size: got {messageSize}, limit {MaxMessageSize}");
            }
        }
Exemple #3
0
        public Task ProcessDeviceMessage(IIdentity identity, IMessage message)
        {
            Preconditions.CheckNotNull(message, nameof(message));
            Preconditions.CheckNotNull(identity, nameof(identity));
            Events.MessageReceived(identity, message);
            IRoutingMessage routingMessage = this.ProcessMessageInternal(message, true);

            Metrics.AddMessageSize(routingMessage.Size(), identity.Id);
            return(this.router.RouteAsync(routingMessage));
        }
Exemple #4
0
 public Task ProcessDeviceMessage(IIdentity identity, IMessage message)
 {
     Preconditions.CheckNotNull(message, nameof(message));
     Preconditions.CheckNotNull(identity, nameof(identity));
     Events.MessageReceived(identity, message);
     MetricsV0.MessageCount(identity, 1);
     using (MetricsV0.MessageLatency(identity))
     {
         IRoutingMessage routingMessage = this.ProcessMessageInternal(message, true);
         Metrics.AddMessageSize(routingMessage.Size(), identity.Id);
         Metrics.AddReceivedMessage(identity.Id, message.GetOutput());
         return(this.router.RouteAsync(routingMessage));
     }
 }
Exemple #5
0
        public Task ProcessDeviceMessageBatch(IIdentity identity, IEnumerable <IMessage> messages)
        {
            IList <IMessage> messagesList = messages as IList <IMessage>
                                            ?? Preconditions.CheckNotNull(messages, nameof(messages)).ToList();

            Events.MessagesReceived(identity, messagesList);

            IEnumerable <IRoutingMessage> routingMessages = messagesList
                                                            .Select(
                m =>
            {
                IRoutingMessage routingMessage = this.ProcessMessageInternal(m, true);
                Metrics.AddMessageSize(routingMessage.Size(), identity.Id);
                return(routingMessage);
            });

            return(this.router.RouteAsync(routingMessages));
        }