public void Setup() { if (_endpointFactoryConfigurator != null) { ConfigurationResult result = ConfigurationResultImpl.CompileResults(_endpointFactoryConfigurator.Validate()); try { EndpointFactory = _endpointFactoryConfigurator.CreateEndpointFactory(); _endpointCache = new EndpointCache(EndpointFactory); EndpointCache = new EndpointCacheProxy(_endpointCache); } catch (Exception ex) { throw new ConfigurationException(result, "An exception was thrown during endpoint cache creation", ex); } } ServiceBusFactory.ConfigureDefaultSettings(x => { x.SetEndpointCache(EndpointCache); x.SetConcurrentConsumerLimit(4); x.SetReceiveTimeout(TimeSpan.FromMilliseconds(50)); x.EnableAutoStart(); x.DisablePerformanceCounters(); }); EstablishContext(); }
void RefreshEndpointCache() { EndpointCache.Clear(); if (CurrentConfiguration >= 0) { foreach (var iface in Configurations[CurrentConfiguration].Interfaces.Values) { var alternate = iface.Current; foreach (var endpoint in alternate.Endpoints.Values) { switch (endpoint.TransferType) { case UsbEndpointType.USB_ENDPOINT_TYPE_CONTROL: // for easy cache lookup, control endpoints are registered as both input and output EndpointCache[(byte)(endpoint.Descriptor.bEndpointAddress & 0x0f)] = endpoint; EndpointCache[(byte)((endpoint.Descriptor.bEndpointAddress & 0x0f) | 0x80)] = endpoint; break; default: EndpointCache[(byte)(endpoint.Descriptor.bEndpointAddress & 0x8f)] = endpoint; break; } } } } }
public void Setup() { if (EndpointFactoryConfigurator != null) { IConfigurationResult result = ConfigurationResult.CompileResults(EndpointFactoryConfigurator.Validate()); try { EndpointFactory = EndpointFactoryConfigurator.CreateEndpointFactory(); EndpointFactoryConfigurator = null; _endpointCache = new EndpointCache(EndpointFactory); EndpointCache = new EndpointCacheProxy(_endpointCache); } catch (Exception ex) { throw new ConfigurationException(result, "An exception was thrown during endpoint cache creation", ex); } } ServiceBusFactory.ConfigureDefaultSettings(x => { x.SetEndpointCache(EndpointCache); x.SetConcurrentConsumerLimit(4); x.SetReceiveTimeout(150.Milliseconds()); x.EnableAutoStart(); }); }
protected override void EstablishContext() { base.EstablishContext(); Endpoint = EndpointCache.GetEndpoint(EndpointAddress.Uri); ErrorEndpoint = EndpointCache.GetEndpoint(ErrorEndpointAddress.Uri); ErrorEndpoint.Receive(x => null, TimeSpan.Zero); }
public void FixtureTeardown() { if (EndpointCache != null) { EndpointCache.Dispose(); EndpointCache = null; } ServiceBusFactory.ConfigureDefaultSettings(x => x.SetEndpointCache(null)); }
private EndpointCache GetOrAddEndpoint(Uri endpoint) { // The GetorAdd is followed by a call to .Count which in a ConcurrentDictionary // will acquire all locks for all buckets. This is really expensive. Since the check // there is only to see if we've exceeded the count of endpoints, we can simply // avoid that check altogether if we are not adding any more endpoints. if (this.addressCacheByEndpoint.TryGetValue(endpoint, out EndpointCache existingCache)) { return(existingCache); } EndpointCache endpointCache = this.addressCacheByEndpoint.GetOrAdd( endpoint, (Uri resolvedEndpoint) => { GatewayAddressCache gatewayAddressCache = new GatewayAddressCache( resolvedEndpoint, this.protocol, this.tokenProvider, this.serviceConfigReader, this.httpClient, enableTcpConnectionEndpointRediscovery: this.enableTcpConnectionEndpointRediscovery); string location = this.endpointManager.GetLocation(endpoint); AddressResolver addressResolver = new AddressResolver(null, new NullRequestSigner(), location); addressResolver.InitializeCaches(this.collectionCache, this.routingMapProvider, gatewayAddressCache); return(new EndpointCache() { AddressCache = gatewayAddressCache, AddressResolver = addressResolver, }); }); if (this.addressCacheByEndpoint.Count > this.maxEndpoints) { IEnumerable <Uri> allEndpoints = this.endpointManager.WriteEndpoints.Union(this.endpointManager.ReadEndpoints); Queue <Uri> endpoints = new Queue <Uri>(allEndpoints.Reverse()); while (this.addressCacheByEndpoint.Count > this.maxEndpoints) { if (endpoints.Count > 0) { EndpointCache removedEntry; this.addressCacheByEndpoint.TryRemove(endpoints.Dequeue(), out removedEntry); } else { break; } } } return(endpointCache); }
IEndpointCache CreateEndpointCache() { if (_settings.EndpointCache != null) { return(_settings.EndpointCache); } IEndpointFactory endpointFactory = CreateEndpointFactory(); IEndpointCache endpointCache = new EndpointCache(endpointFactory); return(endpointCache); }
private EndpointCache GetOrAddEndpoint(Uri endpoint) { EndpointCache endpointCache = this.addressCacheByEndpoint.GetOrAdd( endpoint, (Uri resolvedEndpoint) => { GatewayAddressCache gatewayAddressCache = new GatewayAddressCache( resolvedEndpoint, this.protocol, this.tokenProvider, this.userAgentContainer, this.serviceConfigReader, this.requestTimeout, messageHandler: this.messageHandler, apiType: this.apiType, enableTcpConnectionEndpointRediscovery: this.enableTcpConnectionEndpointRediscovery); string location = this.endpointManager.GetLocation(endpoint); AddressResolver addressResolver = new AddressResolver(null, new NullRequestSigner(), location); addressResolver.InitializeCaches(this.collectionCache, this.routingMapProvider, gatewayAddressCache); return(new EndpointCache() { AddressCache = gatewayAddressCache, AddressResolver = addressResolver, }); }); if (this.addressCacheByEndpoint.Count > this.maxEndpoints) { IEnumerable <Uri> allEndpoints = this.endpointManager.WriteEndpoints.Union(this.endpointManager.ReadEndpoints); Queue <Uri> endpoints = new Queue <Uri>(allEndpoints.Reverse()); while (this.addressCacheByEndpoint.Count > this.maxEndpoints) { if (endpoints.Count > 0) { EndpointCache removedEntry; this.addressCacheByEndpoint.TryRemove(endpoints.Dequeue(), out removedEntry); } else { break; } } } return(endpointCache); }
protected override void EstablishContext() { base.EstablishContext(); LocalEndpoint = EndpointCache.GetEndpoint(LocalEndpointUri); LocalErrorEndpoint = EndpointCache.GetEndpoint(LocalErrorUri); RemoteEndpoint = EndpointCache.GetEndpoint(RemoteEndpointUri); LocalBus = ServiceBusFactory.New(ConfigureLocalBus); RemoteBus = ServiceBusFactory.New(ConfigureRemoteBus); _localLoopback.SetTargetCoordinator(_remoteLoopback.Router); _remoteLoopback.SetTargetCoordinator(_localLoopback.Router); }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_consumerPool != null) { _consumerPool.Stop(); _consumerPool.Dispose(); _consumerPool = null; } if (_serviceContainer != null) { _serviceContainer.Stop(); _serviceContainer.Dispose(); _serviceContainer = null; } if (ControlBus != this) { ControlBus.Dispose(); } if (_performanceCounterConnection != null) { _performanceCounterConnection.Dispose(); _performanceCounterConnection = null; } _eventChannel = null; Endpoint = null; if (_counters != null) { _counters.Dispose(); _counters = null; } EndpointCache.Dispose(); } _disposed = true; }
public void Inspect(DiagnosticsProbe probe) { new StandardDiagnosticsInfo().WriteCommonItems(probe); probe.Add("mt.version", typeof(IServiceBus).Assembly.GetName().Version); probe.Add("mt.receive_from", Endpoint.Address); probe.Add("mt.control_bus", ControlBus.Endpoint.Address); probe.Add("mt.max_consumer_threads", MaximumConsumerThreads); probe.Add("mt.concurrent_receive_threads", ConcurrentReceiveThreads); probe.Add("mt.receive_timeout", ReceiveTimeout); EndpointCache.Inspect(probe); _serviceContainer.Inspect(probe); OutboundPipeline.View(pipe => probe.Add("zz.mt.outbound_pipeline", pipe)); InboundPipeline.View(pipe => probe.Add("zz.mt.inbound_pipeline", pipe)); }
public void ActivityTextFixtureSetup() { if (_endpointFactoryConfigurator != null) { ConfigurationResult result = ConfigurationResultImpl.CompileResults(_endpointFactoryConfigurator.Validate()); try { EndpointFactory = _endpointFactoryConfigurator.CreateEndpointFactory(); _endpointCache = new EndpointCache(EndpointFactory); EndpointCache = new EndpointCacheProxy(_endpointCache); } catch (Exception ex) { throw new ConfigurationException(result, "An exception was thrown during endpoint cache creation", ex); } } ServiceBusFactory.ConfigureDefaultSettings(x => { x.SetEndpointCache(EndpointCache); x.SetConcurrentConsumerLimit(4); x.SetReceiveTimeout(50.Milliseconds()); x.EnableAutoStart(); }); LocalUri = new Uri(BaseUri, "local"); AddCommandContext <DispatchMessageConsumer, DispatchMessage>(() => { var agent = new MessageDispatchAgent(LocalBus); return(new DispatchMessageConsumer(agent)); }); SetupCommands(); LocalBus = CreateServiceBus(ConfigureLocalBus); DispatchEndpoint = LocalBus.GetEndpoint(GetActivityContext <DispatchMessage>().ExecuteUri); }
private dynamic InvokeMethod(object parameters, string methodName) { var parameterTypeFactory = new ParameterTypeFactory(); var endpointFactory = new EndpointFactory(parameterTypeFactory); var pathHelper = new PathHelper(); var configHelper = new ConfigHelper(); var wcfClientBuilder = new WcfClientBuilder(pathHelper); var endpointCache = new EndpointCache(pathHelper); var endpointDefinitionFactory = new EndpointDefinitionFactory(pathHelper, wcfClientBuilder, configHelper); var analysisService = new AnalysisService(endpointFactory, endpointDefinitionFactory, endpointCache); var invocationService = new InvocationService(endpointCache, configHelper); var port = 3030; var address = $"http://localhost:{port}/Services/DummyService.svc"; IList <Endpoint> endpoints = null; try { endpoints = analysisService.AnalyzeAddress(address); } catch (Exception e) { throw new Exception($"Could not analyze service at address {address}. " + "This may be because the service is not running in IIS. To add the service " + "in IIS, add a new website with the following parameters: path=C:\\inetpub\\wwwroot, " + $"binding=http, port={port}, hostname=<blank>. Then right-click this website " + "and select Add Application, using the following parameters: alias=Services, " + "path=<path to WcfPad.DummyWcfService project>. You may also need to give the " + "users IIS_IUSRS and IUSR full access to the WcfPad.DummyWcfService folder. " + $"EXCEPTION MESSAGE: {e.Message}"); } var serializedParameters = JsonConvert.SerializeObject(parameters); dynamic response = invocationService.InvokeMethod(endpoints.FirstOrDefault().Id, methodName, serializedParameters); return(response); }
public static IEndpointCache New([NotNull] Action<EndpointFactoryConfigurator> configure) { Guard.AgainstNull(configure, "configure"); var configurator = new EndpointFactoryConfiguratorImpl(_defaultSettings); configure(configurator); ConfigurationResult result = ConfigurationResultImpl.CompileResults(configurator.Validate()); try { IEndpointFactory endpointFactory = configurator.CreateEndpointFactory(); IEndpointCache endpointCache = new EndpointCache(endpointFactory); return endpointCache; } catch (Exception ex) { throw new ConfigurationException(result, "An exception was thrown during endpoint cache creation", ex); } }
public EndpointTestScenarioImpl(IEndpointFactory endpointFactory) { _received = new ReceivedMessageListImpl(); _sent = new SentMessageListImpl(); _skipped = new ReceivedMessageListImpl(); _endpoints = new Dictionary<Uri, EndpointTestDecorator>(); EndpointFactory = new EndpointFactoryTestDecorator(endpointFactory, this); _endpointCache = new EndpointCache(EndpointFactory); EndpointCache = new EndpointCacheProxy(_endpointCache); ServiceBusFactory.ConfigureDefaultSettings(x => { x.SetEndpointCache(EndpointCache); x.SetConcurrentConsumerLimit(4); x.SetConcurrentReceiverLimit(1); x.SetReceiveTimeout(50.Milliseconds()); x.EnableAutoStart(); }); }
public static IEndpointCache New([NotNull] Action <EndpointFactoryConfigurator> configure) { Guard.AgainstNull(configure, "configure"); var configurator = new EndpointFactoryConfiguratorImpl(_defaultSettings); configure(configurator); ConfigurationResult result = ConfigurationResultImpl.CompileResults(configurator.Validate()); try { IEndpointFactory endpointFactory = configurator.CreateEndpointFactory(); IEndpointCache endpointCache = new EndpointCache(endpointFactory); return(endpointCache); } catch (Exception ex) { throw new ConfigurationException(result, "An exception was thrown during endpoint cache creation", ex); } }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _sent.Dispose(); _received.Dispose(); _endpointCache.Clear(); if (EndpointCache != null) { EndpointCache.Dispose(); EndpointCache = null; } ServiceBusFactory.ConfigureDefaultSettings(x => x.SetEndpointCache(null)); } _disposed = true; }
protected EndpointTestScenarioImpl(IEndpointFactory endpointFactory) { _received = new ReceivedMessageListImpl(); _sent = new SentMessageListImpl(); _skipped = new ReceivedMessageListImpl(); _published = new PublishedMessageListImpl(); _endpoints = new Dictionary <Uri, EndpointTestDecorator>(); EndpointFactory = new EndpointFactoryTestDecorator(endpointFactory, this); _endpointCache = new EndpointCache(EndpointFactory); EndpointCache = new EndpointCacheProxy(_endpointCache); ServiceBusFactory.ConfigureDefaultSettings(x => { x.SetEndpointCache(EndpointCache); x.SetConcurrentConsumerLimit(4); x.SetConcurrentReceiverLimit(1); x.SetReceiveTimeout(50.Milliseconds()); x.EnableAutoStart(); }); }
public void ActivityTextFixtureSetup() { if (_endpointFactoryConfigurator != null) { ConfigurationResult result = ConfigurationResultImpl.CompileResults(_endpointFactoryConfigurator.Validate()); try { EndpointFactory = _endpointFactoryConfigurator.CreateEndpointFactory(); _endpointCache = new EndpointCache(EndpointFactory); EndpointCache = new EndpointCacheProxy(_endpointCache); } catch (Exception ex) { throw new ConfigurationException(result, "An exception was thrown during endpoint cache creation", ex); } } ServiceBusFactory.ConfigureDefaultSettings(x => { x.SetEndpointCache(EndpointCache); x.SetConcurrentConsumerLimit(4); x.SetReceiveTimeout(50.Milliseconds()); x.EnableAutoStart(); }); LocalUri = new Uri(BaseUri, "local"); SetupActivities(); LocalBus = CreateServiceBus(ConfigureLocalBus); }
public IEndpoint GetEndpoint(Uri address) { return(EndpointCache.GetEndpoint(address)); }
IEndpointCache CreateEndpointCache() { if (_settings.EndpointCache != null) return _settings.EndpointCache; IEndpointFactory endpointFactory = CreateEndpointFactory(); IEndpointCache endpointCache = new EndpointCache(endpointFactory); return endpointCache; }