public void Initialize(EntityInfoInternal entity, Func <IncomingMessageDetailsInternal, ReceiveContextInternal, Task> callback, Func <Exception, Task> errorCallback, Action <Exception> criticalError, Func <ErrorContext, Task <ErrorHandleResult> > processingFailureCallback, int maximumConcurrency) { incomingCallback = callback; this.criticalError = criticalError; this.errorCallback = errorCallback ?? EmptyErrorCallback; this.processingFailureCallback = processingFailureCallback; this.entity = entity; fullPath = entity.Path; if (entity.Type == EntityType.Subscription) { var topic = entity.RelationShips.First(r => r.Type == EntityRelationShipTypeInternal.Subscription); fullPath = SubscriptionClient.FormatSubscriptionPath(topic.Target.Path, entity.Path); } wrapInScope = settings.TransportTransactionMode == TransportTransactionMode.SendsAtomicWithReceive; // batching will be applied for transaction modes other than SendsAtomicWithReceive completionCanBeBatched = !wrapInScope; var numberOfClients = settings.NumberOfClients; var concurrency = maximumConcurrency / (double)numberOfClients; maxConcurrentCalls = concurrency > 1 ? (int)Math.Round(concurrency, MidpointRounding.AwayFromZero) : 1; if (Math.Abs(maxConcurrentCalls - concurrency) > 0) { logger.InfoFormat("The maximum concurrency on message receiver instance for '{0}' has been adjusted to '{1}', because the total maximum concurrency '{2}' wasn't divisable by the number of clients '{3}'", fullPath, maxConcurrentCalls, maximumConcurrency, numberOfClients); } internalReceivers = new IMessageReceiverInternal[numberOfClients]; onMessageOptions = new OnMessageOptions[numberOfClients]; // when we don't batch we don't need the completion infrastructure completion = completionCanBeBatched ? new MultiProducerConcurrentCompletion <Guid>(1000, TimeSpan.FromSeconds(1), 6, numberOfClients) : null; }
string GetViaEntityPathFor(EntityInfoInternal entity) { if (entity?.Type == EntityType.Queue) { return(entity.Path); } if (entity?.Type == EntityType.Subscription) { var topicRelationship = entity.RelationShips.First(r => r.Type == EntityRelationShipTypeInternal.Subscription); return(topicRelationship.Target.Path); } return(null); }
protected bool Equals(EntityInfoInternal other) { return(string.Equals(Path, other.Path) && Type == other.Type && Equals(Namespace, other.Namespace)); }
public BrokeredMessageReceiveContextInternal(BrokeredMessage message, EntityInfoInternal entity, ReceiveMode receiveMode) { IncomingBrokeredMessage = message; Entity = entity; ReceiveMode = receiveMode; }