コード例 #1
0
        void SendCacheUpdateToClient(Uri uri, Guid clientId)
        {
            IEndpoint endpoint = _bus.GetEndpoint(uri);

            IEnumerable <SubscriptionClientSaga> sagas = _subscriptionClientSagas
                                                         .Where(x => x.CurrentState == SubscriptionClientSaga.Active && x.ControlUri != uri)
                                                         .ToList();

            sagas.Each(client =>
            {
                _log.DebugFormat("Sending AddClient {0} to {1}", client.CorrelationId, uri);

                var message = new AddSubscriptionClient(client.CorrelationId, client.ControlUri, client.DataUri);

                endpoint.Send(message, x => x.SetSourceAddress(_bus.Endpoint.Address.Uri));
            });

            List <Guid> clients = sagas.Select(x => x.CorrelationId).ToList();

            SubscriptionInformation[] subscriptions = _subscriptionSagas
                                                      .Where(x => x.CurrentState == SubscriptionSaga.Active && clients.Contains(x.SubscriptionInfo.ClientId))
                                                      .Select(x => x.SubscriptionInfo).ToArray();

            _log.InfoFormat("Sending {0} subscriptions to {1}", subscriptions.Length, uri);

            var response = new SubscriptionRefresh(subscriptions);

            endpoint.Send(response, x => x.SetSourceAddress(_bus.Endpoint.Address.Uri));
        }
コード例 #2
0
        public void Consume(SubscriptionClientAdded message)
        {
            _log.Debug(() => string.Format("Subscription Client Added: {0} [{1}]", message.ControlUri, message.ClientId));

            var add = new AddSubscriptionClient(message.ClientId, message.ControlUri, message.DataUri);

            SendClientToClients(add);

            SendCacheUpdateToClient(message.ControlUri, message.ClientId);
        }
コード例 #3
0
        public void Consume(SubscriptionClientAdded message)
        {
            if (_log.IsInfoEnabled)
            {
                _log.InfoFormat("Subscription Client Added: {0} [{1}]", message.ControlUri, message.ClientId);
            }

            var add = new AddSubscriptionClient(message.ClientId, message.ControlUri, message.DataUri);

            SendClientToClients(add);

            SendCacheUpdateToClient(message.ControlUri, message.ClientId);
        }
コード例 #4
0
        private void ConnectToSubscriptionService(IServiceBus bus)
        {
            ConnectSubscriptionPublisherToBus(bus);

            if (bus != bus.ControlBus)
            {
                ConnectSubscriptionPublisherToBus(bus.ControlBus);
            }

            _unsubscribeAction = _bus.ControlBus.Subscribe(this);

            var message = new AddSubscriptionClient(_clientId, _bus.ControlBus.Endpoint.Uri, _bus.Endpoint.Uri);

            _subscriptionServiceEndpoint.Send(message);
        }
コード例 #5
0
 public void ShouldForwardAndTranslate()
 {
     var message = new AddSubscriptionClient(_clientId, _controlUri, _dataUri); // why isn't this working?
     MockNewSubEndpoint.AssertWasCalled(e=>e.Send(message), c=>c.IgnoreArguments());
 }
コード例 #6
0
        public void ShouldForwardAndTranslate()
        {
            var message = new AddSubscriptionClient(_clientId, _controlUri, _dataUri); // why isn't this working?

            MockNewSubEndpoint.AssertWasCalled(e => e.Send(message), c => c.IgnoreArguments());
        }