/// <summary>
        /// This method resolves the client and processes the message.
        /// </summary>
        /// <param name="payload">The payload to transmit.</param>
        public virtual async Task SenderTransmit(TransmissionPayload payload)
        {
            int?         start  = null;
            ClientHolder sender = null;

            try
            {
                sender = SenderClientResolve(payload.Message.ChannelPriority);

                start = sender.StatisticsInternal.ActiveIncrement();

                await sender.Transmit(payload);

                payload.TraceWrite($"Sent: {sender.Name}", "MessagingSenderBase/ProcessMessage");
            }
            catch (Exception ex)
            {
                LogExceptionLocation($"{nameof(SenderTransmit)} (Unhandled)", ex);
                //OK, not sure what happened here, so we need to throw the exception.
                payload.TraceWrite($"Exception: {ex.Message}", "MessagingSenderBase/ProcessMessage");
                if (sender != null)
                {
                    sender.StatisticsInternal.ErrorIncrement();
                }
                throw;
            }
            finally
            {
                if (sender != null && start.HasValue)
                {
                    sender.StatisticsInternal.ActiveDecrement(start.Value);
                }
            }
        }
        /// <summary>
        /// This is the main constructor.
        /// </summary>
        /// <param name="resourceTracker">The resource tracker.</param>
        /// <param name="client">The client to hold.</param>
        /// <param name="mappingChannelId">The mapping channel.param>
        /// <param name="maxAllowedPollWait">The maximum permitted poll length.</param>
        public ClientPriorityHolder(IResourceTracker resourceTracker
                                    , ClientHolder client
                                    , string mappingChannelId
                                    , IListenerClientPollAlgorithm priorityAlgorithm
                                    )
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (priorityAlgorithm == null)
            {
                throw new ArgumentNullException("algorithm");
            }

            mPriorityAlgorithm = priorityAlgorithm;

            Client = client;

            mMappingChannel = mappingChannelId;

            //Create the metrics container to hold the calculations for poll priority and reservation amount.
            mMetrics = new ClientPriorityHolderMetrics(mPriorityAlgorithm
                                                       , resourceTracker?.RegisterRequestRateLimiter(client.Name, client.ResourceProfiles)
                                                       , client.Priority
                                                       , client.Weighting
                                                       );

            mPriorityAlgorithm.InitialiseMetrics(mMetrics);
        }
Exemplo n.º 3
0
 /// <summary>
 /// This method triggers a revalidates of the particular client.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="newList">The new list of message filter wrappers.</param>
 protected abstract void ListenerClientValidate(ClientHolder client, List <MessageFilterWrapper> newList);
Exemplo n.º 4
0
 protected override void ListenerClientValidate(ClientHolder client, List <MessageFilterWrapper> newList)
 {
     throw new NotImplementedException();
 }