public static RebusConfigurer ConfigureEndpoint(this RebusConfigurer configurer, EndpointRole role) { configurer .Logging(l => l.Serilog(Log.Logger)) .Transport(t => { if (role == EndpointRole.Client) { t.UseMsmqAsOneWayClient(); } else { t.UseMsmq(Config.AppSetting("QueueName")); } }) .Subscriptions(s => { var subscriptionsTableName = Config.AppSetting("SubscriptionsTableName"); s.StoreInSqlServer("RebusDatabase", subscriptionsTableName, isCentralized: true); }) .Sagas(s => { if (role != EndpointRole.SagaHost) return; var dataTableName = Config.AppSetting("SagaDataTableName"); var indexTableName = Config.AppSetting("SagaIndexTableName"); // store sagas in SQL Server to make them persistent and survive restarts s.StoreInSqlServer("RebusDatabase", dataTableName, indexTableName); }) .Timeouts(t => { if (role == EndpointRole.Client) return; var tableName = Config.AppSetting("TimeoutsTableName"); // store timeouts in SQL Server to make them persistent and survive restarts t.StoreInSqlServer("RebusDatabase", tableName); }); return configurer; }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { base.ElementPropertyChanged(e); Association element = (Association)e.ModelElement; Store store = element.Store; Transaction current = store.TransactionManager.CurrentTransaction; if (current.IsSerializing) { return; } if (Equals(e.NewValue, e.OldValue)) { return; } List <string> errorMessages = EFCoreValidator.GetErrors(element).ToList(); switch (e.DomainProperty.Name) { case "Persistent": UpdateDisplayForPersistence(element); break; case "SourceDeleteAction": DeleteAction sourceDeleteAction = (DeleteAction)e.NewValue; UpdateDisplayForCascadeDelete(element, sourceDeleteAction); break; case "SourceMultiplicity": Multiplicity sourceMultiplicity = (Multiplicity)e.NewValue; // change unidirectional source cardinality // if target is dependent // source cardinality is 0..1 or 1 if (element.Target.IsDependentType && sourceMultiplicity == Multiplicity.ZeroMany) { errorMessages.Add($"Can't have a 0..* association from {element.Target.Name} to dependent type {element.Source.Name}"); break; } if ((sourceMultiplicity == Multiplicity.One && element.TargetMultiplicity == Multiplicity.One) || (sourceMultiplicity == Multiplicity.ZeroOne && element.TargetMultiplicity == Multiplicity.ZeroOne)) { if (element.SourceRole != EndpointRole.NotSet) { element.SourceRole = EndpointRole.NotSet; } if (element.TargetRole != EndpointRole.NotSet) { element.TargetRole = EndpointRole.NotSet; } } else { SetEndpointRoles(element); } UpdateDisplayForCascadeDelete(element, null, null, sourceMultiplicity); break; case "SourcePropertyName": string sourcePropertyNameErrorMessage = ValidateAssociationIdentifier(element, element.Target, (string)e.NewValue); if (EFModelDiagram.IsDropping && sourcePropertyNameErrorMessage != null) { element.Delete(); } else { errorMessages.Add(sourcePropertyNameErrorMessage); } break; case "SourceRole": if (element.Source.IsDependentType) { element.SourceRole = EndpointRole.Dependent; element.TargetRole = EndpointRole.Principal; } else { EndpointRole sourceRole = (EndpointRole)e.NewValue; if (sourceRole == EndpointRole.Dependent && element.TargetRole != EndpointRole.Principal) { element.TargetRole = EndpointRole.Principal; } else if (sourceRole == EndpointRole.Principal && element.TargetRole != EndpointRole.Dependent) { element.TargetRole = EndpointRole.Dependent; } SetEndpointRoles(element); } break; case "TargetDeleteAction": DeleteAction targetDeleteAction = (DeleteAction)e.NewValue; UpdateDisplayForCascadeDelete(element, null, targetDeleteAction); break; case "TargetMultiplicity": Multiplicity newTargetMultiplicity = (Multiplicity)e.NewValue; // change unidirectional target cardinality // if target is dependent // target cardinality must be 0..1 or 1 if (element.Target.IsDependentType && newTargetMultiplicity == Multiplicity.ZeroMany) { errorMessages.Add($"Can't have a 0..* association from {element.Source.Name} to dependent type {element.Target.Name}"); break; } if ((element.SourceMultiplicity == Multiplicity.One && newTargetMultiplicity == Multiplicity.One) || (element.SourceMultiplicity == Multiplicity.ZeroOne && newTargetMultiplicity == Multiplicity.ZeroOne)) { if (element.SourceRole != EndpointRole.NotSet) { element.SourceRole = EndpointRole.NotSet; } if (element.TargetRole != EndpointRole.NotSet) { element.TargetRole = EndpointRole.NotSet; } } else { SetEndpointRoles(element); } UpdateDisplayForCascadeDelete(element, null, null, null, newTargetMultiplicity); break; case "TargetPropertyName": // if we're creating an association via drag/drop, it's possible the existing property name // is the same as the default property name. The default doesn't get created until the transaction is // committed, so the drop's action will cause a name clash. Remove the clashing property, but // only if drag/drop. string targetPropertyNameErrorMessage = ValidateAssociationIdentifier(element, element.Source, (string)e.NewValue); if (EFModelDiagram.IsDropping && targetPropertyNameErrorMessage != null) { element.Delete(); } else { errorMessages.Add(targetPropertyNameErrorMessage); } break; case "TargetRole": if (element.Target.IsDependentType) { element.SourceRole = EndpointRole.Principal; element.TargetRole = EndpointRole.Dependent; } else { EndpointRole targetRole = (EndpointRole)e.NewValue; if (targetRole == EndpointRole.Dependent && element.SourceRole != EndpointRole.Principal) { element.SourceRole = EndpointRole.Principal; } else if (targetRole == EndpointRole.Principal && element.SourceRole != EndpointRole.Dependent) { element.SourceRole = EndpointRole.Dependent; } SetEndpointRoles(element); } break; } errorMessages = errorMessages.Where(m => m != null).ToList(); if (errorMessages.Any()) { current.Rollback(); ErrorDisplay.Show(string.Join("\n", errorMessages)); } }