Exemplo n.º 1
0
 /// <summary>
 /// Инициализирует новый экземпляр класса
 /// </summary>
 /// <param name="bytes">массив байт</param>
 public CreateSubscriptionResponse(byte[] bytes)
     : base(bytes)
 {
     if (Header.ReturnCode == ReturnCode.Successfull)
     {
         subscriptionId = SubscriptionId.Parse(bytes, SctpProtocol.HeaderLength);
     }
 }
 private string DetailInfo(
     SubscriptionId subscriptionId,
     string indicationType,
     IDictionary <string, object> indicationProperties,
     IDictionary <string, object> sourceInstanceProperties)
 {
     return(string.Format("Pub/Sub Notification: ID: {0}, Type: {1}, IndicationProperties: {2}, InstanceProperties: {3}", (object)subscriptionId, (object)indicationType, (object)string.Join(", ", indicationProperties.Select <KeyValuePair <string, object>, string>((Func <KeyValuePair <string, object>, string>)(kvp => string.Format("{0} = {1}", (object)kvp.Key, kvp.Value)))), sourceInstanceProperties.Count > 0 ? (object)string.Join(", ", sourceInstanceProperties.Select <KeyValuePair <string, object>, string>((Func <KeyValuePair <string, object>, string>)(kvp => string.Format("{0} = {1}", (object)kvp.Key, kvp.Value)))) : (object)string.Empty));
 }
Exemplo n.º 3
0
    /// <inheritdoc/>
    public async Task <StreamPosition> GetNextEventToReceiveFor(SubscriptionId subscriptionId, CancellationToken cancellationToken)
    {
        var tryGetState = await _repository.TryGetFor(subscriptionId, cancellationToken).ConfigureAwait(false);

        return(tryGetState.Success
            ? tryGetState.Result.Position
            : StreamPosition.Start);
    }
 protected override InSingleProcessMemorySubscription NewSubscribeSubscription(Type messageType, SubscriptionId subscriptionId, TopicId topicId, SubscriptionMode subscriptionMode,
     bool acceptMessagesOlderThanSubscriptionTime, Action<object> messageHandler, string queueName)
 {
     return new InSingleProcessMemoryAuthorizedSubscription(
         this, AuthorizedMessageOperation.Subscribe, subscriptionId, topicId, messageType, queueName,
         subscriptionMode, acceptMessagesOlderThanSubscriptionTime, messageHandler, null, null, null
     );
 }
        public async Task <AtomDocument> GetHeadDocument(SubscriptionId subscriptionId)
        {
            var documentId = await factory.GetActorRef().Ask <DocumentId>(new GetHeadDocumentIdForFeedRequest(subscriptionId));

            var atomDocument = await shardedAtomDocumentFactory.GetActorRef().Ask <AtomDocument>(new GetAtomDocumentRequest(documentId));

            return(atomDocument);
        }
    public override string ToString()
    {
        var  sb      = new StringBuilder("FetchSquareChatEventsRequest(");
        bool __first = true;

        if (__isset.subscriptionId)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("SubscriptionId: ");
            SubscriptionId.ToString(sb);
        }
        if (SquareChatMid != null && __isset.squareChatMid)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("SquareChatMid: ");
            SquareChatMid.ToString(sb);
        }
        if (SyncToken != null && __isset.syncToken)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("SyncToken: ");
            SyncToken.ToString(sb);
        }
        if (__isset.limit)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Limit: ");
            Limit.ToString(sb);
        }
        if (__isset.direction)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Direction: ");
            Direction.ToString(sb);
        }
        sb.Append(")");
        return(sb.ToString());
    }
 public SendSubscriptionRenewalConfirmationEmailCommand(
     Guid id,
     SubscriptionId subscriptionId,
     string email)
     : base(id)
 {
     SubscriptionId = subscriptionId;
     Email          = email;
 }
Exemplo n.º 8
0
        public void RemoveObservation(Type eventType, SubscriptionId subscriptionId, SourceId sourceId)
        {
            var observation = ExistingObservation(eventType, subscriptionId, sourceId);

            if (observation != null)
            {
                RemoveObservation(observation);
            }
        }
Exemplo n.º 9
0
        public void RemoveSubscription(Type messageType, SubscriptionId subscriptionId)
        {
            var subscription = ExistingSubscriptionFor(messageType, subscriptionId);

            if (subscription != null)
            {
                RemoveSubscription(subscription);
            }
        }
Exemplo n.º 10
0
        public async Task <AtomDocument> GetHeadDocument(SubscriptionId subscriptionId)
        {
            _adapter.Info($"requesting head document for id {subscriptionId.Id}");
            var documentId = await burstManager.SubscriptionActorRef.Ask <DocumentId>(new GetHeadDocumentIdForFeedRequest(subscriptionId));

            var document = await _documentRepository.GetDocument(documentId);

            return(document);
        }
 public virtual bool Unsubscribe(SubscriptionId id)
 {
     if (!mapping.TryRemove(id, out var disposable))
     {
         return(false);
     }
     disposable?.Dispose();
     return(true);
 }
        public override int GetHashCode()
        {
            int hashCode = 1685690023;

            if (Context != null)
            {
                hashCode += Context.GetHashCode();
            }

            if (AccessToken != null)
            {
                hashCode += AccessToken.GetHashCode();
            }

            if (TokenType != null)
            {
                hashCode += TokenType.GetHashCode();
            }

            if (ExpiresAt != null)
            {
                hashCode += ExpiresAt.GetHashCode();
            }

            if (MerchantId != null)
            {
                hashCode += MerchantId.GetHashCode();
            }

            if (SubscriptionId != null)
            {
                hashCode += SubscriptionId.GetHashCode();
            }

            if (PlanId != null)
            {
                hashCode += PlanId.GetHashCode();
            }

            if (IdToken != null)
            {
                hashCode += IdToken.GetHashCode();
            }

            if (RefreshToken != null)
            {
                hashCode += RefreshToken.GetHashCode();
            }

            if (ShortLived != null)
            {
                hashCode += ShortLived.GetHashCode();
            }

            return(hashCode);
        }
Exemplo n.º 13
0
        private void AnalyzerInternal(bool checkARM = true, bool checkRDFE = true)
        {
            (var arm, var rdfe) = CallARMAndRDFE(checkARM, checkRDFE);
            (var type, var dep) = DetectVMType(arm, rdfe);

            if (dep == null && IsCustomRun == false)
            {
                try
                {
                    var instance = AnalyzeARMResourceURI(SubscriptionId.ToString(), ResourceGroupName, VMName);
                    GlobalInfo.Update(
                        new Guid(instance.Last().ContainerId),
                        new Guid(instance.Last().NodeId),
                        instance.Last().Cluster
                        );

                    if (!string.IsNullOrWhiteSpace(instance.FirstOrDefault().Usage_ResourceGroupName))
                    {
                        this.ResourceGroupName = instance.FirstOrDefault().Usage_ResourceGroupName;
                    }
                    this.VMName = instance.FirstOrDefault().RoleInstanceName;
                }
                catch
                {
                    try
                    {
                        var instance = AnalyzeRDFEResourceURI(SubscriptionId.ToString(), ResourceGroupName, VMName);
                        GlobalInfo.Update(
                            new Guid(instance.Last().ContainerId),
                            new Guid(instance.Last().NodeId),
                            instance.Last().Cluster
                            );
                        this.ResourceGroupName = instance.FirstOrDefault().TenantId;
                        this.VMName            = instance.FirstOrDefault().RoleInstanceName;
                    }
                    catch
                    {
                        SALsA.GetInstance(Id).State = SALsAState.NotFound;
                        throw new Exception("VM not found");
                    }
                }

                (type, dep) = DetectVMType(arm, rdfe);

                if (dep == null && IsCustomRun == false)
                {
                    SALsA.GetInstance(Id).ICM.QueueICMDiscussion(String.Format("Could not find VM: {0} in RG: {1}. This VM might have been already deleted or moved",
                                                                               this.VMName, this.ResourceGroupName));

                    // Lets try to check kusto data
                    SALsA.GetInstance(Id).TaskManager.AddTask(
                        BlobStorageUtility.SaveAndSendBlobTask(Constants.AnalyzerNodeDiagnosticsFilename, GenevaActions.GetNodeDiagnosticsFilesByContainerId(Id, GlobalInfo), Id));
                }
            }
            CallInternalComputeTypes(type, dep);
        }
 private void When(SubscriptionRenewalPaymentCreatedDomainEvent @event)
 {
     this.Id             = @event.SubscriptionRenewalPaymentId;
     _payerId            = new PayerId(@event.PayerId);
     _subscriptionId     = new SubscriptionId(@event.SubscriptionId);
     _subscriptionPeriod = SubscriptionPeriod.Of(@event.SubscriptionPeriodCode);
     _countryCode        = @event.CountryCode;
     _subscriptionRenewalPaymentStatus = SubscriptionRenewalPaymentStatus.Of(@event.Status);
     _value = MoneyValue.Of(@event.Value, @event.Currency);
 }
Exemplo n.º 15
0
        private ARMSubscription AnalyzeARMSubscriptionResult(string json)
        {
            var armSubscription = Utility.JsonToObject <ARMSubscriptionRaw>(json);

            if (armSubscription.value == null)
            {
                return(null);
            }
            var armAnalysed = new Dictionary <string, ARMDeployment>();

            foreach (var deployment in armSubscription.value)
            {
                try
                {
                    //"id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/{provider}/{type}/{name}",
                    var id = deployment.id.Split('/');
                    if (!Constants.AnalyszerARMDeploymentTypes.Contains(deployment.type.Split('/')[1]))
                    {
                        continue;
                    }
                    var dep = new ARMDeployment
                    {
                        Subscriptions  = SubscriptionId.ToString(),
                        ResourceGroups = id[4],
                        Location       = Constants.CRPRegions.Where(x => String.Equals(x, deployment.location, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(),
                        Name           = deployment.name.Contains("/") ? deployment.name.Split('/')[0] : deployment.name,
                        Type           = deployment.type.Split('/')[1]
                    };
                    if (String.IsNullOrEmpty(dep.Location))
                    {
                        dep.Location = deployment.location;
                    }
                    if (!armAnalysed.ContainsKey(dep.Name))
                    {
                        armAnalysed[dep.Name] = dep;
                    }
                    if (deployment.type.Split('/').Last() == Constants.AnalyzerARMDeploymentExtensionType)
                    {
                        armAnalysed[dep.Name].Extensions.Add(id.Last());;
                    }
                }
                catch (Exception)
                {
                    Log.Warning("Unable to get or analyse the ARM deployment {0}", deployment);
                    continue;
                }
            }
            var deployments = new ARMSubscription()
            {
                deployments = armAnalysed.Values.Cast <ARMDeployment>().ToList()
            };

            return(deployments);
        }
Exemplo n.º 16
0
 private bool Equals(EventHistoryTableEntity other)
 {
     return(string.Equals(PartitionKey, other.PartitionKey) &&
            string.Equals(RowKey, other.RowKey) &&
            Created.Equals(other.Created) &&
            string.Equals(EventType, other.EventType) &&
            string.Equals(OperationName, other.OperationName) &&
            OrganizationId.Equals(other.OrganizationId) &&
            SubscriptionId.Equals(other.SubscriptionId) &&
            string.Equals(Data, other.Data));
 }
Exemplo n.º 17
0
        async Task ReadEventsFromEventHorizon(
            ConsentId consentId,
            SubscriptionId subscriptionId,
            IReverseCallClient <EventHorizonConsumerToProducerMessage, EventHorizonProducerToConsumerMessage, ConsumerSubscriptionRequest, Contracts.SubscriptionResponse, ConsumerRequest, ConsumerResponse> reverseCallClient)
        {
            _logger.Information("Successfully connected event horizon with {subscriptionId}. Waiting for events to process", subscriptionId);
            var queue         = new AsyncProducerConsumerQueue <StreamEvent>();
            var eventsFetcher = new EventsFromEventHorizonFetcher(queue);

            using var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_cancellationToken);
            var tasks = new List <Task>();

            try
            {
                _subscriptions.TrySubscribe(
                    consentId,
                    subscriptionId,
                    new EventProcessor(consentId, subscriptionId, _eventHorizonEventsWriter, _eventProcessorPolicy, _logger),
                    eventsFetcher,
                    linkedTokenSource.Token,
                    out var outputtedStreamProcessor);
                using var streamProcessor = outputtedStreamProcessor;
                await streamProcessor.Initialize().ConfigureAwait(false);

                tasks.Add(Task.Run(async() =>
                {
                    await reverseCallClient.Handle(
                        (request, cancellationToken) => HandleConsumerRequest(subscriptionId, queue, request, cancellationToken),
                        linkedTokenSource.Token).ConfigureAwait(false);
                    linkedTokenSource.Cancel();
                }));
                tasks.Add(streamProcessor.Start());
            }
            catch (Exception ex)
            {
                linkedTokenSource.Cancel();
                _logger.Warning(ex, "Error occurred while initializing Subscription: {subscriptionId}", subscriptionId);
                return;
            }

            var finishedTask = await Task.WhenAny(tasks).ConfigureAwait(false);

            if (!linkedTokenSource.IsCancellationRequested)
            {
                linkedTokenSource.Cancel();
            }
            if (TryGetException(tasks, out var exception))
            {
                linkedTokenSource.Cancel();
                _logger.Warning(exception, "Error occurred while processing Subscription: {subscriptionId}", subscriptionId);
            }

            await Task.WhenAll(tasks).ConfigureAwait(false);
        }
Exemplo n.º 18
0
        public static void Main(string[] args)
        {
            var akkaSystemName     = GetValueFromCommandLine("akkaSystemName", args);
            var seedNodes          = GetValueFromCommandLine("seedNodes", args);
            var akkaPortNumber     = GetIntFromCommandLine(args, "portNumber");
            var entriesPerDocument = GetIntFromCommandLine(args, "entriesPerDocument");
            var persistence        = GetValueFromCommandLine("persistence", args);

            var eventSystemHost        = new BurstingEventSystemHost(akkaPortNumber, akkaSystemName, persistence, seedNodes, 3601, entriesPerDocument);
            var EventRaisingController = eventSystemHost.Get <EventRaisingController>();

            eventSystemHost.Start();

            Console.Title = string.Join(" ", args);
            Thread.Sleep(TimeSpan.FromSeconds(5));

            var subscriptionId = new SubscriptionId(GetValueFromCommandLine("subscriptionId", args));

            if (!string.IsNullOrEmpty(subscriptionId.Id))
            {
                Console.WriteLine("Getting subscriptionId");
                ISubscriptionManager shardedSubscriptionManager = eventSystemHost.Get <ISubscriptionManager>();

                var currentSubscription =
                    shardedSubscriptionManager.GetSubscriptionDetails(new SubscriptionQuery(subscriptionId)).Result;

                if (currentSubscription is NullSubscription)
                {
                    _subscriptionMessage = new SubscriptionMessage(
                        new AtomNotificationChannel(),
                        subscriptionId,
                        new AllEventMatcher());

                    shardedSubscriptionManager.CreateSubscription(_subscriptionMessage);
                    Thread.Sleep(1000);
                }

                Thread.Sleep(1000);

                IEventPublisher notifier = eventSystemHost.Get <IEventPublisher>();

                var i = 0;
                while (true)
                {
                    notifier.PublishMessage(new DummyDomainEvent(akkaPortNumber + ":" + (++i).ToString()));
                    LogManager.GetLogger("").Info("Raising event with id" + i);
                }
            }

            while (true)
            {
                Thread.Sleep(TimeSpan.FromSeconds(5));
            }
        }
Exemplo n.º 19
0
        public Subscription GetSubscription(SubscriptionId id)
        {
            var events = _eventsStore.GetEventsOfAggregate(id).ToArray();

            if (!events.Any())
            {
                throw new UnknownSubscription(id);
            }

            return(new Subscription(events));
        }
Exemplo n.º 20
0
 public override int GetHashCode()
 {
     unchecked // Overflow is fine
     {
         int hash = 17;
         hash = hash * 23 + (SubscriptionId != null ? SubscriptionId.GetHashCode() : 0);
         hash = hash * 23 + (TenantId != null ? TenantId.GetHashCode() : 0);
         hash = hash * 23 + (DisplayName != null ? DisplayName.GetHashCode() : 0);
         hash = hash * 23 + (State != null ? State.GetHashCode() : 0);
         return(hash);
     }
 }
Exemplo n.º 21
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (BusUri != null
                           ? BusUri.GetHashCode()
                           : 0);
         result = (result * 397) ^ PeerId.GetHashCode();
         result = (result * 397) ^ SubscriptionId.GetHashCode();
         return(result);
     }
 }
Exemplo n.º 22
0
 /// <inheritdoc />
 public ISubscription Create(SubscriptionId subscriptionId, MicroserviceAddress producerMicroserviceAddress, ExecutionContext executionContext)
 => new Subscription(
     subscriptionId,
     producerMicroserviceAddress,
     executionContext,
     _subscriptionPolicies,
     _eventHorizonConnectionFactory,
     _streamProcessorFactory,
     _subscriptionPositions,
     _metrics,
     _processingMetrics,
     _loggerFactory.CreateLogger <Subscription>());
Exemplo n.º 23
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = SubscriptionId.GetHashCode();
                hashCode = (hashCode * 397) ^ (OrganizationId?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (UserId?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (EventData?.GetHashCode() ?? 0);

                return(hashCode);
            }
        }
Exemplo n.º 24
0
 private void RegisterObserverForLaunchedEvents(SubscriptionId subscriptionId, IEnumerable <MonitoredEvent> observations, Action <IEvent> eventHandler)
 {
     observations.ForEach(observation =>
     {
         DomainEvents.Observe(observation.EventType,
                              (launchedEvent) =>
         {
             eventHandler(launchedEvent);
         }, subscriptionId, observation.SourceId);
     });
     WaitForVerification(1);
 }
Exemplo n.º 25
0
        private EventObservation <TEvent> Observe(Type eventType, SubscriptionId subscriptionId, SourceId sourceId, Action <TEvent> eventHandler)
        {
            var observation = ExistingObservation(eventType, subscriptionId, sourceId);

            if ((observation != null) && (observation.EventHandler != null))
            {
                throw new InvalidOperationException(String.Format("There is already a observation for event type '{0}' and observation id {1} and source id {2}", eventType, subscriptionId, sourceId));
            }

            observation = NewObservation(eventType, subscriptionId, sourceId, eventHandler);

            return(observation);
        }
Exemplo n.º 26
0
    static ConsumerSubscriptionRequest CreateRequest(SubscriptionId subscription, StreamPosition publicEventsPosition)
    {
        var request = new ConsumerSubscriptionRequest
        {
            PartitionId    = subscription.PartitionId.Value,
            StreamId       = subscription.StreamId.ToProtobuf(),
            StreamPosition = publicEventsPosition.Value,
            TenantId       = subscription.ProducerTenantId.ToProtobuf()
        };

        request.TrySetPartitionIdLegacy();
        return(request);
    }
Exemplo n.º 27
0
        private EventObservation <TEvent> NewObservation(Type eventType, SubscriptionId subscriptionId, SourceId sourceId, Action <TEvent> eventHandler)
        {
            Log.Debug("Acquired lock to ActiveObservations at method NewSubscriptionFor(...)");
            var observation = new EventObservation <TEvent>(eventType, subscriptionId, sourceId, eventHandler);

            lock (ActiveObservations)
            {
                ActiveObservations[new Tuple <Type, SubscriptionId, SourceId>(eventType, subscriptionId, sourceId)] = observation;
            }
            Log.Debug("Released lock to ActiveObservations at method NewSubscriptionFor(...)");

            return(observation);
        }
Exemplo n.º 28
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = TenantId != null?TenantId.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ SubscriptionId.GetHashCode();
                hashCode = (hashCode * 397) ^ (ResourceGroup != null ? ResourceGroup.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ ClientId.GetHashCode();
                hashCode = (hashCode * 397) ^ (ClientSecret != null ? ClientSecret.GetHashCode() : 0);
                return(hashCode);
            }
        }
        protected SubscriptionPaymentTestData CreateSubscriptionPaymentTestData()
        {
            var payerId        = new PayerId(Guid.NewGuid());
            var subscriptionId = new SubscriptionId(Guid.NewGuid());
            var priceList      = CreatePriceList();

            var subscriptionPaymentTestData = new SubscriptionPaymentTestData(
                priceList,
                payerId,
                subscriptionId);

            return(subscriptionPaymentTestData);
        }
        public RabbitMQSubscription(
            IRabbitMQMessageBus messageBus, SubscriptionId subscriptionId, TopicId topicId, 
            Type messageType, string queueName, SubscriptionMode subscriptionMode, bool acceptMessagesOlderThanSubscriptionTime, 
            Action<object> messageHandler, 
            Action<object, object> messageHandlerWithProperties, 
            Action<object, Dictionary<string, string>> messageHandlerWithHeaders, 
            Action<object, object, Dictionary<string, string>> messageHandlerWithPropertiesAndHeaders)
            : base(subscriptionId, topicId, messageType, queueName, subscriptionMode, acceptMessagesOlderThanSubscriptionTime, messageHandler, messageHandlerWithProperties, messageHandlerWithHeaders, messageHandlerWithPropertiesAndHeaders)
        {
            if (topicId == null) throw new ArgumentNullException("topicId");

            MessageBus = messageBus;
        }
        public async Task OnNotificationAsync(Notification notification)
        {
            RollupModeChangedSubscriber changedSubscriber1 = this;

            if (changedSubscriber1.subscription == null)
            {
                return;
            }
            Notification notification1 = notification;
            string       str;

            if (notification1 == null)
            {
                str = (string)null;
            }
            else
            {
                SubscriptionId subscriptionId = notification1.get_SubscriptionId();
                str = ((SubscriptionId) ref subscriptionId).get_UniqueName();
            }
            string subscriptionUniqueName = RollupModeChangedSubscriber.SubscriptionUniqueName;

            if (str != subscriptionUniqueName)
            {
                return;
            }
            if (notification.get_SourceInstanceProperties() == null)
            {
                RollupModeChangedSubscriber.log.Error((object)"Argument SourceInstanceProperties is null.");
            }
            else if (!notification.get_SourceInstanceProperties().ContainsKey("Core.StatusRollupMode"))
            {
                RollupModeChangedSubscriber.log.Error((object)"Core.StatusRollupMode not supplied in SourceInstanceProperties.");
            }
            else
            {
                try
                {
                    RollupModeChangedSubscriber changedSubscriber = changedSubscriber1;
                    string           instanceProperty             = (string)notification.get_SourceInstanceProperties()["Core.StatusRollupMode"];
                    EvaluationMethod evaluationMethod             = instanceProperty != null ? (EvaluationMethod)Convert.ToInt32(instanceProperty) : (EvaluationMethod)0;
                    int nodeId = Convert.ToInt32(notification.get_SourceInstanceProperties()["NodeId"]);
                    RollupModeChangedSubscriber.log.DebugFormat("Node with id '{0}' rollup mode changed to '{1}', re-calculating node status ..", (object)nodeId, (object)evaluationMethod);
                    await Task.Run((Action)(() => changedSubscriber.RecalculateNodeStatus(nodeId)));
                }
                catch (Exception ex)
                {
                    RollupModeChangedSubscriber.log.Error((object)"Indication handling failed", ex);
                }
            }
        }
Exemplo n.º 32
0
        public Task OnNotificationAsync(Notification notification)
        {
            Task <bool> task = Task.FromResult <bool>(false);

            if (this.subscription != null)
            {
                string str1;
                if (notification == null)
                {
                    str1 = (string)null;
                }
                else
                {
                    SubscriptionId subscriptionId = notification.get_SubscriptionId();
                    str1 = ((SubscriptionId) ref subscriptionId).get_UniqueName();
                }
                string subscriptionUniqueName = NodeChildStatusParticipationSubscriber.SubscriptionUniqueName;
                if (!(str1 != subscriptionUniqueName))
                {
                    if (notification.get_SourceInstanceProperties() == null)
                    {
                        NodeChildStatusParticipationSubscriber.log.Error((object)"Argument SourceInstanceProperties is null.");
                        return((Task)task);
                    }
                    if (notification.get_SourceInstanceProperties().ContainsKey("EntityType"))
                    {
                        if (notification.get_SourceInstanceProperties().ContainsKey("Enabled"))
                        {
                            try
                            {
                                string str2 = Convert.ToString(notification.get_SourceInstanceProperties()["EntityType"]);
                                string str3 = Convert.ToBoolean(notification.get_SourceInstanceProperties()["Enabled"]) ? "enabled" : "disabled";
                                NodeChildStatusParticipationSubscriber.log.DebugFormat("Node child status participation for '" + str2 + "' is " + str3 + ", re-calculating node status ..", Array.Empty <object>());
                                this.reflowScheduler?.Change(-1, -1);
                                this.reflowScheduler = this.SetupReflowScheduler();
                                return((Task)Task.FromResult <bool>(this.reflowScheduler.Change(this.delay, -1)));
                            }
                            catch (Exception ex)
                            {
                                NodeChildStatusParticipationSubscriber.log.Error((object)"Indication handling failed", ex);
                            }
                            return((Task)task);
                        }
                    }
                    NodeChildStatusParticipationSubscriber.log.Error((object)"The EntityType or Enabled not supplied in SourceInstanceProperties.");
                    return((Task)task);
                }
            }
            return((Task)task);
        }
        protected Subscription(
            SubscriptionId subscriptionId, TopicId topicId, Type messageType,
            string queueName,
            SubscriptionMode subscriptionMode,
            bool acceptMessagesOlderThanSubscriptionTime, 
            Action<object> messageHandler,
            Action<object, object> messageHandlerWithProperties,
            Action<object, Dictionary<string, string>> messageHandlerWithHeaders,
            Action<object, object, Dictionary<string, string>> messageHandlerWithPropertiesAndHeaders)
        {
            if ((messageHandler != null) && (messageHandlerWithProperties != null))
                throw new ArgumentException("MessageHandler and MessageHandlerWithProperties cannot be both assigned!");

            SubscriptionId = subscriptionId;
            TopicId = topicId;
            MessageType = messageType;
            SubscriptionMode = subscriptionMode;
            AcceptMessagesOlderThanSubscriptionTime = acceptMessagesOlderThanSubscriptionTime;
            MessageHandler = messageHandler;
            MessageHandlerWithHeaders = messageHandlerWithHeaders;
            MessageHandlerWithProperties = messageHandlerWithProperties;
            MessageHandlerWithPropertiesAndHeaders = messageHandlerWithPropertiesAndHeaders;
            QueueName = queueName;
        }
 public DeleteSubscriptionMessage(SubscriptionId subscriptionId)
 {
     SubscriptionId = subscriptionId;
 }
Exemplo n.º 35
0
 public UserUnfollowed(SubscriptionId subscriptionId)
     : this()
 {
     SubscriptionId = subscriptionId;
 }
 protected override RabbitMQSubscription NewReceivingSubscription(Type messageType, SubscriptionId subscriptionId, SubscriptionMode subscriptionMode,
     bool acceptMessagesOlderThanSubscriptionTime, Action<object> messageHandler, string queueName)
 {
     return new RabbitMQAuthorizedSubscription(
         this, AuthorizedMessageOperation.Receive, subscriptionId, TopicId.None, messageType, queueName, 
         subscriptionMode, acceptMessagesOlderThanSubscriptionTime, messageHandler, null, null, null
     );
 }
 protected static string QueueNameFor(Type messageType, SubscriptionId subscriptionId)
 {
     //Ex: ReactiveServices.ComputationalUnit.Dispatching.LaunchConfirmation:ComputationalUnit.Dispatching_LaunchConfirmationSubscriptionFor_DispatcherLauncherId#c73c2193-a8c5-47b6-ac5a-cde91a4c788b‏
     //Pattern: FullTypeName:AssemblyName_SubscriptionId
     return String.Format("{0}:{1}_{2}", messageType.FullName, messageType.Assembly.GetName().Name, subscriptionId.Value);
 }
        protected override void TrySend(
            Type messageType, object message, SubscriptionId subscriptionId, StorageType storageType,
            bool waitForPublishConfirmation, TimeSpan publishConfirmationTimeout,
            Dictionary<string, string> headers, TimeSpan expiration)
        {
            InSingleProcessMemoryAuthorizer.Verify(AuthorizedMessageOperation.Send, messageType, message, headers);

            base.TrySend(messageType, message, subscriptionId, storageType, waitForPublishConfirmation, publishConfirmationTimeout, headers, expiration);
        }
Exemplo n.º 39
0
 public SubscriptionQuery(SubscriptionId subscriptionId)
 {
     SubscriptionId = subscriptionId;
 }
 public InSingleProcessMemoryAuthorizedSubscription(IInSingleProcessMemoryMessageBus messageBus, AuthorizedMessageOperation operation, SubscriptionId subscriptionId, TopicId topicId, Type messageType, string queueName, SubscriptionMode subscriptionMode, bool acceptMessagesOlderThanSubscriptionTime, Action<object> messageHandler, Action<object, object> messageHandlerWithProperties, Action<object, Dictionary<string, string>> messageHandlerWithHeaders, Action<object, object, Dictionary<string, string>> messageHandlerWithPropertiesAndHeaders)
     : base(messageBus, subscriptionId, topicId, messageType, queueName, subscriptionMode, acceptMessagesOlderThanSubscriptionTime, messageHandler, messageHandlerWithProperties, messageHandlerWithHeaders, messageHandlerWithPropertiesAndHeaders)
 {
     Operation = operation;
 }
        protected override void TryPublishRequest(
            Type requestType, IRequest request, string correlationId, string replyQueueName,
            SubscriptionId subscriptionId, Dictionary<string, string> headers, TimeSpan expiration)
        {
            InSingleProcessMemoryAuthorizer.Verify(AuthorizedMessageOperation.Request, requestType, request, headers);

            base.TryPublishRequest(requestType, request, correlationId, replyQueueName, subscriptionId, headers, expiration);
        }