public void Configure(AzureServiceBusQueueConfig configSection, TransportConfig transportConfig) { var config = NServiceBus.Configure.Instance; ConfigureCreationInfrastructure(config, configSection, transportConfig); ConfigureReceiveInfrastructure(config, configSection); if (!config.Configurer.HasComponent<ISendMessages>()) { ConfigureSendInfrastructure(config, configSection); } if (!config.Configurer.HasComponent<IPublishMessages>() && !config.Configurer.HasComponent<IManageSubscriptions>()) { ConfigurePublishingInfrastructure(config, configSection); } }
private void ConfigureCreationInfrastructure(Configure config, AzureServiceBusQueueConfig configSection, TransportConfig transportConfig) { config.Configurer.ConfigureComponent<CreatesMessagingFactories>(DependencyLifecycle.InstancePerCall); config.Configurer.ConfigureComponent<CreatesNamespaceManagers>(DependencyLifecycle.InstancePerCall); config.Configurer.ConfigureComponent<AzureServicebusQueueClientCreator>(DependencyLifecycle.InstancePerCall); config.Configurer.ConfigureProperty<AzureServicebusQueueClientCreator>(t => t.MaxRetries, transportConfig.MaxRetries); config.Configurer.ConfigureComponent<AzureServiceBusQueueCreator>(DependencyLifecycle.InstancePerCall); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.LockDuration, TimeSpan.FromMilliseconds(configSection.LockDuration)); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.MaxSizeInMegabytes, configSection.MaxSizeInMegabytes); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.RequiresDuplicateDetection, configSection.RequiresDuplicateDetection); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.RequiresSession, configSection.RequiresSession); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.DefaultMessageTimeToLive, TimeSpan.FromMilliseconds(configSection.DefaultMessageTimeToLive)); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.EnableDeadLetteringOnMessageExpiration, configSection.EnableDeadLetteringOnMessageExpiration); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.DuplicateDetectionHistoryTimeWindow, TimeSpan.FromMilliseconds(configSection.DuplicateDetectionHistoryTimeWindow)); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.MaxDeliveryCount, configSection.MaxDeliveryCount); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.EnableBatchedOperations, configSection.EnableBatchedOperations); config.Configurer.ConfigureProperty<AzureServiceBusQueueCreator>(t => t.EnablePartitioning, configSection.EnablePartitioning); config.Configurer.ConfigureComponent<AzureServicebusTopicClientCreator>(DependencyLifecycle.InstancePerCall); config.Configurer.ConfigureComponent<AzureServicebusTopicCreator>(DependencyLifecycle.InstancePerCall); config.Configurer.ConfigureProperty<AzureServicebusTopicCreator>(t => t.EnablePartitioning, configSection.EnablePartitioning); config.Configurer.ConfigureComponent<AzureServicebusSubscriptionClientCreator>(DependencyLifecycle.InstancePerCall); config.Configurer.ConfigureProperty<AzureServicebusSubscriptionClientCreator>(t => t.MaxRetries, transportConfig.MaxRetries); config.Configurer.ConfigureComponent<AzureServicebusSubscriptionCreator>(DependencyLifecycle.InstancePerCall); config.Configurer.ConfigureProperty<AzureServicebusSubscriptionCreator>(t => t.LockDuration, TimeSpan.FromMilliseconds(configSection.LockDuration)); config.Configurer.ConfigureProperty<AzureServicebusSubscriptionCreator>(t => t.RequiresSession, configSection.RequiresSession); config.Configurer.ConfigureProperty<AzureServicebusSubscriptionCreator>(t => t.DefaultMessageTimeToLive, TimeSpan.FromMilliseconds(configSection.DefaultMessageTimeToLive)); config.Configurer.ConfigureProperty<AzureServicebusSubscriptionCreator>(t => t.EnableDeadLetteringOnMessageExpiration, configSection.EnableDeadLetteringOnMessageExpiration); config.Configurer.ConfigureProperty<AzureServicebusSubscriptionCreator>(t => t.EnableDeadLetteringOnFilterEvaluationExceptions, configSection.EnableDeadLetteringOnFilterEvaluationExceptions); config.Configurer.ConfigureProperty<AzureServicebusSubscriptionCreator>(t => t.MaxDeliveryCount, configSection.MaxDeliveryCount); config.Configurer.ConfigureProperty<AzureServicebusSubscriptionCreator>(t => t.EnableBatchedOperations, configSection.EnableBatchedOperations); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TransportConfig obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
public int transportCreate(pjsip_transport_type_e type, TransportConfig cfg) { int ret = pjsua2PINVOKE.Endpoint_transportCreate(swigCPtr, (int)type, TransportConfig.getCPtr(cfg)); if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve(); return ret; }
public void TestBindConfig() { // Create a domain participant DomainParticipant participant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_OTHER_DOMAIN); Assert.IsNotNull(participant); participant.BindRtpsUdpTransportConfig(); // Create a transport config TransportConfig config = TransportRegistry.Instance.CreateConfig(nameof(TestBindConfig)); Assert.IsNotNull(config); // Bind the participant using the name bool exception = false; try { TransportRegistry.Instance.BindConfig(nameof(TestBindConfig), participant); } catch { exception = true; } Assert.IsFalse(exception); // Bind the participant using the transport config exception = false; try { TransportRegistry.Instance.BindConfig(config, participant); } catch { exception = true; } Assert.IsFalse(exception); // Test parameters guards exception = false; try { TransportRegistry.Instance.BindConfig((string)null, participant); } catch (Exception ex) { exception = true; Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException)); } Assert.IsTrue(exception); exception = false; try { TransportRegistry.Instance.BindConfig("", participant); } catch (Exception ex) { exception = true; Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException)); } Assert.IsTrue(exception); exception = false; try { TransportRegistry.Instance.BindConfig(" ", participant); } catch (Exception ex) { exception = true; Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException)); } Assert.IsTrue(exception); exception = false; try { TransportRegistry.Instance.BindConfig(nameof(TestBindConfig), null); } catch (Exception ex) { exception = true; Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException)); } Assert.IsTrue(exception); exception = false; try { TransportRegistry.Instance.BindConfig((TransportConfig)null, participant); } catch (Exception ex) { exception = true; Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException)); } Assert.IsTrue(exception); exception = false; try { TransportRegistry.Instance.BindConfig(config, null); } catch (Exception ex) { exception = true; Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException)); } Assert.IsTrue(exception); }
public LongRunningConnection(IPAddress address, TransportConfig config, KeyspaceConfig keyspaceConfig, ILogger logger, IInstrumentation instrumentation) { try { for (byte streamId = 0; streamId < MAX_STREAMID; ++streamId) { _availableStreamIds.Push(streamId); } _config = config; _keyspaceConfig = keyspaceConfig; _logger = logger; _instrumentation = instrumentation; Endpoint = address; DefaultConsistencyLevel = config.DefaultConsistencyLevel; DefaultExecutionFlags = config.DefaultExecutionFlags; _tcpClient = new TcpClient { ReceiveTimeout = _config.ReceiveTimeout, SendTimeout = _config.SendTimeout, NoDelay = true, LingerState = { Enabled = true, LingerTime = 0 }, }; IAsyncResult asyncResult = _tcpClient.BeginConnect(address, _config.Port, null, null); bool success = asyncResult.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(_config.ConnectionTimeout), true); if (!success) { throw new InvalidOperationException("Connection timeout occured."); } if (!_tcpClient.Connected) { _tcpClient.Close(); throw new InvalidOperationException("Can't connect to node."); } _tcpClient.EndConnect(asyncResult); _socket = _tcpClient.Client; _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, _config.KeepAlive); if (_config.KeepAlive && 0 != _config.KeepAliveTime) { SetTcpKeepAlive(_socket, _config.KeepAliveTime, 1000); } _pushResult = _config.ReceiveBuffering ? (Action <QueryInfo, IFrameReader, bool>)((qi, fr, a) => Task.Factory.StartNew(() => PushResult(qi, fr, a))) : PushResult; _responseWorker = Task.Factory.StartNew(() => RunWorker(ReadResponse), TaskCreationOptions.LongRunning); _queryWorker = Task.Factory.StartNew(() => RunWorker(SendQuery), TaskCreationOptions.LongRunning); // readify the connection _logger.Debug("Readyfying connection for {0}", Endpoint); //GetOptions(); ReadifyConnection(); _logger.Debug("Connection to {0} is ready", Endpoint); } catch (Exception ex) { Dispose(); _logger.Error("Failed building connection {0}", ex); throw; } }
public void UpdateTransportConfig(TransportConfig configuration) { throw new NotImplementedException(); }