Exemple #1
0
        public AzureServiceBusRelayEventStoreProxy(string serviceNamespace, string servicePath, string keyName, string sharedAccessKey, NetTcpRelayBinding netTcpRelayBinding = null)
        {
            var uri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, servicePath);

            _logger.Info("Initializing event store facade for {0}", uri);

            var binding = netTcpRelayBinding ?? BindingHelper.CreateDefaultRelayBinding();

            _channelFactory = new ChannelFactory <IHostService>(binding, new EndpointAddress(uri));

            var tokenProvider    = TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, sharedAccessKey);
            var endpointBehavior = new TransportClientEndpointBehavior(tokenProvider);

            _channelFactory.Endpoint.Behaviors.Add(endpointBehavior);
        }
        public AzureServiceBusRelayEventDispatcher(IEventStore eventStore, string serviceNamespace, string path, string keyName, string sharedAccessKey, NetTcpRelayBinding netTcpRelayBinding = null)
        {
            var uri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, path);

            _logger.Info("Initializing service bus relay host for {0}", uri);

            _serviceHost = new ServiceHost(new HostService(eventStore));

            var binding       = netTcpRelayBinding ?? BindingHelper.CreateDefaultRelayBinding();
            var tokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, sharedAccessKey);

            var endpoint         = _serviceHost.AddServiceEndpoint(typeof(IHostService), binding, uri);
            var endpointBehavior = new TransportClientEndpointBehavior(tokenProvider);

            endpoint.Behaviors.Add(endpointBehavior);
        }