/// <summary> /// Processes the required actions for an inbound connector. /// </summary> /// <param name="connector">The inbound connector to process.</param> private void ProcessInboundConnector(IInboundConnector connector) { this.Info("Inbound connector '{0}'-'{1}' is running.", connector.ID, connector.Description); while (_shutdownEvent.WaitOne(0) == false) { IConnection connection = connector.WaitForConnections(); if (connection != null) { this.Trace("Accepted new incomming connection '{0}' from connector '{1}'-'{2}'.", connection.ID, connector.ID, connector.Description); _converterManager.CreateConverterStream(connection, _converterAssignments[connector.ID]); } else { if (_shutdownEvent.WaitOne(0) == false) { this.Error("Waiting for incomming connections from connector '{0}'-'{1}' failed -> process wait and try again.", connector.ID, connector.Description); Thread.Sleep(1000); } } } }
public void SetInboundConnector(IInboundConnector configuration) { SessionParameters sessionParameters = this.BuildParameters(configuration); sessionParameters.Set("Identity", configuration.Identity.ToString()); base.RemotePowershellSession.RunCommand("Set-InboundConnector", sessionParameters); }
public void Stop() { this.listening = false; this.inConnector.Cancel(); this.listenThread.Join(); this.inConnector.Dispose(); this.inConnector = null; this.convertor.Dispose(); this.convertor = null; this.shutdownEvent.Set(); foreach (IConverterStream converterStream in this.converterStreamList.ToArray()) { converterStream.Cancel(); converterStream.Dispose(); } while (Interlocked.CompareExchange(ref this.numberReadingThread, 0, 0) != 0) { Thread.Sleep(50); } this.shutdownEvent.Reset(); }
public OffsetStoredInboundConnectorTests() { var services = new ServiceCollection(); _testSubscriber = new TestSubscriber(); services.AddSingleton <ILoggerFactory, NullLoggerFactory>(); services.AddSingleton(typeof(ILogger <>), typeof(NullLogger <>)); services .AddSilverback() .WithConnectionTo <TestBroker>() .AddSingletonSubscriber(_testSubscriber); services.AddScoped <IOffsetStore, InMemoryOffsetStore>(); IServiceProvider serviceProvider = services.BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true }); _broker = (TestBroker)serviceProvider.GetService <IBroker>(); _connector = new OffsetStoredInboundConnector(_broker, serviceProvider, new NullLogger <OffsetStoredInboundConnector>(), new MessageLogger()); _scopedServiceProvider = serviceProvider.CreateScope().ServiceProvider; InMemoryOffsetStore.Clear(); }
public OffsetStoredInboundConnectorTests() { var services = new ServiceCollection(); _testSubscriber = new TestSubscriber(); services.AddSingleton <ISubscriber>(_testSubscriber); services.AddSingleton <ILoggerFactory, NullLoggerFactory>(); services.AddSingleton(typeof(ILogger <>), typeof(NullLogger <>)); services.AddBus(); services.AddBroker <TestBroker>(); services.AddScoped <IOffsetStore, InMemoryOffsetStore>(); _serviceProvider = services.BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true }); _broker = (TestBroker)_serviceProvider.GetService <IBroker>(); _connector = new OffsetStoredInboundConnector(_broker, _serviceProvider, new NullLogger <OffsetStoredInboundConnector>(), new MessageLogger(new MessageKeyProvider(new[] { new DefaultPropertiesMessageKeyProvider() }))); _scopedServiceProvider = _serviceProvider.CreateScope().ServiceProvider; InMemoryOffsetStore.Clear(); }
public InboundConnectorTests() { var services = new ServiceCollection(); _testSubscriber = new TestSubscriber(); _inboundSubscriber = new WrappedInboundMessageSubscriber(); _someUnhandledMessageSubscriber = new SomeUnhandledMessageSubscriber(); services.AddSingleton <ILoggerFactory, NullLoggerFactory>(); services.AddSingleton(typeof(ILogger <>), typeof(NullLogger <>)); services .AddSilverback() .AddSingletonSubscriber(_testSubscriber) .AddSingletonSubscriber(_inboundSubscriber) .AddSingletonSubscriber(_someUnhandledMessageSubscriber) .WithConnectionTo <TestBroker>(options => options .AddChunkStore <InMemoryChunkStore>()); var serviceProvider = services.BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true }); _broker = (TestBroker)serviceProvider.GetService <IBroker>(); _connector = new InboundConnector(_broker, serviceProvider); _errorPolicyBuilder = new ErrorPolicyBuilder(serviceProvider, NullLoggerFactory.Instance); }
public IInboundConnector NewInboundConnector(IInboundConnector configuration) { SessionParameters parameters = this.BuildParameters(configuration); TenantInboundConnector tenantInboundConnector = base.RemotePowershellSession.RunOneCommandSingleResult <TenantInboundConnector>("New-InboundConnector", parameters, false); if (tenantInboundConnector != null) { return(new InboundConnector(tenantInboundConnector)); } return(null); }
private void ValidateFopeConnectorsAreUpgraded(ITaskContext taskContext) { IOrganizationConfig organizationConfig = base.OnPremisesSession.GetOrganizationConfig(); IOnPremisesOrganization onPremisesOrganization = base.TenantSession.GetOnPremisesOrganization(organizationConfig.Guid); IInboundConnector inboundConnector = base.TenantSession.GetInboundConnector(onPremisesOrganization.InboundConnector.ToString()); IOutboundConnector outboundConnector = base.TenantSession.GetOutboundConnector(onPremisesOrganization.OutboundConnector.ToString()); if (inboundConnector.ConnectorSource != TenantConnectorSource.HybridWizard || outboundConnector.ConnectorSource != TenantConnectorSource.HybridWizard) { throw new LocalizedException(HybridStrings.ErrorHybridOnPremisesOrganizationWasNotCreatedWithUpgradedConnectors); } }
private SessionParameters BuildParameters(IInboundConnector configuration) { SessionParameters sessionParameters = new SessionParameters(); sessionParameters.Set("Name", configuration.Name); sessionParameters.Set("ConnectorType", configuration.ConnectorType); sessionParameters.Set("RequireTLS", configuration.RequireTls); sessionParameters.Set <AddressSpace>("SenderDomains", configuration.SenderDomains); sessionParameters.Set("TLSSenderCertificateName", configuration.TLSSenderCertificateName); sessionParameters.Set("CloudServicesMailEnabled", configuration.CloudServicesMailEnabled); return(sessionParameters); }
private void UpgradeFopeConnectors(ITaskContext taskContext) { MultiValuedProperty <SmtpDomain> multiValuedProperty = new MultiValuedProperty <SmtpDomain>(); foreach (SmtpDomain item in base.TaskContext.HybridConfigurationObject.Domains) { multiValuedProperty.Add(item); } IOrganizationConfig organizationConfig = base.OnPremisesSession.GetOrganizationConfig(); List <string> domains = new List <string>(); OrganizationRelationship organizationRelationship = TaskCommon.GetOrganizationRelationship(base.OnPremisesSession, Configuration.OnPremGetOrgRel, domains); OrganizationRelationship organizationRelationship2 = TaskCommon.GetOrganizationRelationship(base.TenantSession, Configuration.TenantGetOrgRel, domains); if (organizationRelationship2 == null || organizationRelationship == null) { throw new LocalizedException(HybridStrings.InvalidOrganizationRelationship); } string onPremOrgRelationshipName = TaskCommon.GetOnPremOrgRelationshipName(organizationConfig); string tenantOrgRelationshipName = TaskCommon.GetTenantOrgRelationshipName(organizationConfig); SessionParameters sessionParameters = new SessionParameters(); SessionParameters sessionParameters2 = new SessionParameters(); sessionParameters.Set("Name", onPremOrgRelationshipName); sessionParameters2.Set("Name", tenantOrgRelationshipName); base.OnPremisesSession.SetOrganizationRelationship(organizationRelationship.Identity, sessionParameters); base.TenantSession.SetOrganizationRelationship(organizationRelationship2.Identity, sessionParameters2); organizationRelationship2 = TaskCommon.GetOrganizationRelationship(base.TenantSession, tenantOrgRelationshipName, domains); if (organizationRelationship2 == null) { throw new LocalizedException(HybridStrings.InvalidOrganizationRelationship); } IInboundConnector inboundConnector = base.TenantSession.GetInboundConnectors().FirstOrDefault((IInboundConnector x) => x.ConnectorSource == TenantConnectorSource.HybridWizard); if (inboundConnector == null) { throw new LocalizedException(HybridStrings.ErrorNoInboundConnector); } base.TenantSession.RenameInboundConnector(inboundConnector, Configuration.InboundConnectorName(organizationConfig.Guid.ToString())); IOutboundConnector outboundConnector = base.TenantSession.GetOutboundConnectors().FirstOrDefault((IOutboundConnector x) => x.ConnectorSource == TenantConnectorSource.HybridWizard); if (outboundConnector == null) { throw new LocalizedException(HybridStrings.ErrorNoOutboundConnector); } base.TenantSession.RenameOutboundConnector(outboundConnector, Configuration.OutboundConnectorName(organizationConfig.Guid.ToString())); base.TenantSession.NewOnPremisesOrganization(organizationConfig, multiValuedProperty, inboundConnector, outboundConnector, organizationRelationship2); }
public LoggedInboundConnectorTests() { var services = new ServiceCollection(); _testSubscriber = new TestSubscriber(); services.AddSingleton <ILoggerFactory, NullLoggerFactory>(); services.AddSingleton(typeof(ILogger <>), typeof(NullLogger <>)); services .AddSilverback() .WithConnectionTo <TestBroker>() .AddSingletonSubscriber(_testSubscriber); services.AddScoped <IInboundLog, InMemoryInboundLog>(); _serviceProvider = services.BuildServiceProvider(); _broker = (TestBroker)_serviceProvider.GetService <IBroker>(); _connector = new LoggedInboundConnector(_broker, _serviceProvider, new NullLogger <LoggedInboundConnector>(), new MessageLogger()); InMemoryInboundLog.Clear(); }
public LoggedInboundConnectorTests() { var services = new ServiceCollection(); _testSubscriber = new TestSubscriber(); services.AddSingleton <ISubscriber>(_testSubscriber); services.AddSingleton <ILoggerFactory, NullLoggerFactory>(); services.AddSingleton(typeof(ILogger <>), typeof(NullLogger <>)); services.AddBus(); services.AddBroker <TestBroker>(); services.AddScoped <IInboundLog, InMemoryInboundLog>(); _serviceProvider = services.BuildServiceProvider(); _broker = (TestBroker)_serviceProvider.GetService <IBroker>(); _connector = new LoggedInboundConnector(_broker, _serviceProvider, new NullLogger <LoggedInboundConnector>(), new MessageLogger(new MessageKeyProvider(new[] { new DefaultPropertiesMessageKeyProvider() }))); InMemoryInboundLog.Clear(); }
public bool Listen(int port, int subscriberID, int handshakeTimeout, bool enableKeepAlive, int keepAliveInterval, int keepAliveTimeOut, bool useExternalIdAsSerialNumber) { if (this.listening) { throw new System.Exception("StorageSystemSimulatorCore already Listening"); } List <ConfigurationValue> configurationForTcpInConnector = this.GetConfigurationForTcpInConnector(port); this.inConnector = new TcpInConnector(); if (!this.inConnector.Initialize(1, configurationForTcpInConnector)) { return(false); } List <ConfigurationValue> configurationForWwksConverter = this.GetConfigurationForWwksConverter( subscriberID, handshakeTimeout, enableKeepAlive, keepAliveInterval, keepAliveTimeOut, useExternalIdAsSerialNumber); this.convertor = new WwksConverter(); this.convertor.Initialize(2, configurationForWwksConverter); this.inputCore.SetSubscriberID(subscriberID); _simulatorArticleInfoCore.SetSubscriberID(subscriberID); this.listening = true; this.listenThread = new Thread(this.ExecuteListen); this.listenThread.Name = "StorageSystemSimulator Listen thread"; this.listenThread.Start(); StorageSystemSerializer storageSystemSerializer = new StorageSystemSerializer(); storageSystemSerializer.SaveConnectionInformation("Connection.xml", configurationForTcpInConnector, configurationForWwksConverter); return(true); }
private bool DoTenantConnectorsNeedConfiguration() { this.onPremisesOrganizationOperation = MailFlowTask.Operation.NOP; this.inboundConnectorOperation = MailFlowTask.Operation.NOP; this.outboundConnectorOperation = MailFlowTask.Operation.NOP; this.onPremisesOrganization = base.TenantSession.GetOnPremisesOrganization(this.OnPremOrgConfig.Guid); string identity = this.DefaultInboundConnectorName; string identity2 = this.DefaultOutboundConnectorName; if (this.onPremisesOrganization == null) { this.onPremisesOrganizationOperation = MailFlowTask.Operation.New; } else { if (this.onPremisesOrganization.InboundConnector != null) { identity = this.onPremisesOrganization.InboundConnector.ToString(); } if (this.onPremisesOrganization.OutboundConnector != null) { identity2 = this.onPremisesOrganization.OutboundConnector.ToString(); } } this.inboundConnector = base.TenantSession.GetInboundConnector(identity); if (this.inboundConnector == null) { if (this.EnableSecureMail) { this.inboundConnectorOperation = MailFlowTask.Operation.New; } } else if (this.EnableSecureMail) { IInboundConnector obj = this.BuildExpectedInboundConnector(null); if (!this.inboundConnector.Equals(obj)) { this.inboundConnectorOperation = MailFlowTask.Operation.Update; } } else { this.inboundConnectorOperation = MailFlowTask.Operation.Remove; } this.outboundConnector = base.TenantSession.GetOutboundConnector(identity2); if (this.outboundConnector == null) { if (this.EnableSecureMail) { this.outboundConnectorOperation = MailFlowTask.Operation.New; } } else if (this.EnableSecureMail) { IOutboundConnector obj2 = this.BuildExpectedOutboundConnector(null); if (!this.outboundConnector.Equals(obj2)) { this.outboundConnectorOperation = MailFlowTask.Operation.Update; } } else { this.outboundConnectorOperation = MailFlowTask.Operation.Remove; } if (this.onPremisesOrganization != null) { ADObjectId b = (this.inboundConnector == null) ? null : this.inboundConnector.Identity; ADObjectId b2 = (this.outboundConnector == null) ? null : this.outboundConnector.Identity; if (this.inboundConnectorOperation == MailFlowTask.Operation.New || this.inboundConnectorOperation == MailFlowTask.Operation.Remove || this.outboundConnectorOperation == MailFlowTask.Operation.New || this.outboundConnectorOperation == MailFlowTask.Operation.Remove || !TaskCommon.AreEqual(this.onPremisesOrganization.InboundConnector, b) || !TaskCommon.AreEqual(this.onPremisesOrganization.OutboundConnector, b2) || !TaskCommon.ContainsSame <SmtpDomain>(this.onPremisesOrganization.HybridDomains, this.HybridDomains) || !string.Equals(this.onPremisesOrganization.OrganizationName, this.OnPremOrgConfig.Name, StringComparison.InvariantCultureIgnoreCase) || !TaskCommon.AreEqual(this.onPremisesOrganization.OrganizationRelationship, (ADObjectId)this.TenantOrganizationRelationship.Identity)) { this.onPremisesOrganizationOperation = MailFlowTask.Operation.Update; } } return(this.onPremisesOrganizationOperation != MailFlowTask.Operation.NOP || this.inboundConnectorOperation != MailFlowTask.Operation.NOP || this.outboundConnectorOperation != MailFlowTask.Operation.NOP); }
public void SetOnPremisesOrganization(IOnPremisesOrganization configuration, IOrganizationConfig onPremisesOrgConfig, MultiValuedProperty <SmtpDomain> hybridDomains, IInboundConnector inboundConnector, IOutboundConnector outboundConnector, OrganizationRelationship tenantOrgRel) { Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization onPremisesOrganization = (Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization)configuration; onPremisesOrganization.HybridDomains = hybridDomains; onPremisesOrganization.InboundConnector = inboundConnector.Identity; onPremisesOrganization.OutboundConnector = outboundConnector.Identity; onPremisesOrganization.OrganizationName = onPremisesOrgConfig.Name; onPremisesOrganization.OrganizationRelationship = (ADObjectId)tenantOrgRel.Identity; SessionParameters sessionParameters = this.BuildParameters(configuration); sessionParameters.Set("Identity", configuration.Identity.ToString()); base.RemotePowershellSession.RunCommand("Set-OnPremisesOrganization", sessionParameters); }
public IOnPremisesOrganization NewOnPremisesOrganization(IOrganizationConfig onPremisesOrgConfig, MultiValuedProperty <SmtpDomain> hybridDomains, IInboundConnector inboundConnector, IOutboundConnector outboundConnector, OrganizationRelationship tenantOrgRel) { Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization onPremisesOrganization = new Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization(onPremisesOrgConfig.Guid, onPremisesOrgConfig.Name, hybridDomains, inboundConnector.Identity, outboundConnector.Identity, onPremisesOrgConfig.Guid.ToString(), (ADObjectId)tenantOrgRel.Identity); SessionParameters sessionParameters = this.BuildParameters(onPremisesOrganization); sessionParameters.Set("Name", onPremisesOrganization.Name); sessionParameters.Set("OrganizationGuid", onPremisesOrganization.OrganizationGuid); Microsoft.Exchange.Data.Directory.SystemConfiguration.OnPremisesOrganization onPremisesOrganization2 = base.RemotePowershellSession.RunOneCommandSingleResult <Microsoft.Exchange.Data.Directory.SystemConfiguration.OnPremisesOrganization>("New-OnPremisesOrganization", sessionParameters, false); if (onPremisesOrganization2 != null) { return(new Microsoft.Exchange.Management.Hybrid.Entity.OnPremisesOrganization { Identity = (ADObjectId)onPremisesOrganization2.Identity, OrganizationGuid = onPremisesOrganization2.OrganizationGuid, OrganizationName = onPremisesOrganization2.OrganizationName, HybridDomains = onPremisesOrganization2.HybridDomains, InboundConnector = onPremisesOrganization2.InboundConnector, OutboundConnector = onPremisesOrganization2.OutboundConnector, Name = onPremisesOrganization2.Name, OrganizationRelationship = onPremisesOrganization2.OrganizationRelationship }); } return(null); }
public void RenameInboundConnector(IInboundConnector c, string name) { ((InboundConnector)c).Name = name; this.SetInboundConnector(c); }