Exposes settings related to routing.
Inheritance: ExposeSettings
        public void WhenPassingTransportAddressForPublisherInsteadOfEndpointName_UsingAssemblyAndNamespace_ShouldThrowException()
        {
            var routingSettings = new RoutingSettings<MessageDrivenTransportDefinition>(new SettingsHolder());

            var exception = Assert.Throws<ArgumentException>(() => routingSettings.RegisterPublisher(Assembly.GetExecutingAssembly(), nameof(EventNamespace), "EndpointName@MyHost"));
            Assert.AreEqual(expectedExceptionMessageForWrongEndpointName, exception.Message);
        }
        public void WhenPassingTransportAddressForSenderInsteadOfEndpointName_UsingAssemblyAndNamespace_ShouldThrowException()
        {
            var routingSettings = new RoutingSettings(new SettingsHolder());
            var expectedExceptionMessage = expectedExceptionMessageForWrongEndpointName;

            var exception = Assert.Throws<ArgumentException>(() => routingSettings.RouteToEndpoint(Assembly.GetExecutingAssembly(), nameof(MessageNamespaceA), "EndpointName@MyHost"));
            Assert.AreEqual(expectedExceptionMessage, exception.Message);
        }
        public void WhenPassingEndpointNameForPublisher_ShouldAddRouteToPublishers()
        {
            var routingSettings = new RoutingSettings<MessageDrivenTransportDefinition>(new SettingsHolder());
            routingSettings.RegisterPublisher(typeof(Event), "EndpointName");

            var publishers = ApplyPublisherRegistrations(routingSettings);

            var publishersForEvent = publishers.GetPublisherFor(typeof(Event)).SingleOrDefault();
            Assert.IsNotNull(publishersForEvent);
        }
        public void WhenRoutingMessageTypeToEndpoint_ShouldConfigureMessageTypeInRoutingTable()
        {
            var routingSettings = new RoutingSettings(new SettingsHolder());
            routingSettings.RouteToEndpoint(typeof(SomeMessageType), "destination");

            var routingTable = ApplyConfiguredRoutes(routingSettings);
            var route = routingTable.GetRouteFor(typeof(SomeMessageType));

            Assert.That(route, Is.Not.Null);
            Assert.That(route.Endpoint, Is.EqualTo("destination"));
        }
        public void WhenPassingEndpointNameForPublisher_UsingAssemblyAndNamespace_ShouldAddEventsWithNamespaceToPublishers()
        {
            var routingSettings = new RoutingSettings<MessageDrivenTransportDefinition>(new SettingsHolder());
            routingSettings.RegisterPublisher(Assembly.GetExecutingAssembly(), nameof(EventNamespace), "EndpointName");

            var publishers = ApplyPublisherRegistrations(routingSettings);

            var publishersForEvent = publishers.GetPublisherFor(typeof(Event)).SingleOrDefault();
            var publishersForEventWithNamespace = publishers.GetPublisherFor(typeof(EventWithNamespace)).SingleOrDefault();

            Assert.IsNull(publishersForEvent);
            Assert.IsNotNull(publishersForEventWithNamespace);
        }
        public void WhenRoutingAssemblyWithNamespaceToEndpoint_ShouldOnlyConfigureMessagesWithinThatNamespace()
        {
            var routingSettings = new RoutingSettings(new SettingsHolder());
            routingSettings.RouteToEndpoint(Assembly.GetExecutingAssembly(), nameof(MessageNamespaceA), "destination");

            var routingTable = ApplyConfiguredRoutes(routingSettings);

            var someMessageRoute = routingTable.GetRouteFor(typeof(SomeMessageType));
            var otherMessageRoute = routingTable.GetRouteFor(typeof(OtherMessageType));
            var messageWithoutNamespaceRoute = routingTable.GetRouteFor(typeof(MessageWithoutNamespace));

            Assert.That(someMessageRoute, Is.Not.Null, "because SomeMessageType is in the given namespace");
            Assert.That(otherMessageRoute, Is.Null, "because OtherMessageType is not in the given namespace");
            Assert.That(messageWithoutNamespaceRoute, Is.Null, "because MessageWithoutNamespace is not in the given namespace");
        }
        public void WhenRoutingAssemblyToEndpoint_ShouldConfigureAllContainedMessagesInRoutingTable()
        {
            var routingSettings = new RoutingSettings(new SettingsHolder());
            routingSettings.RouteToEndpoint(Assembly.GetExecutingAssembly(), "destination");

            var routingTable = ApplyConfiguredRoutes(routingSettings);

            var someMessageRoute = routingTable.GetRouteFor(typeof(SomeMessageType));
            var otherMessageRoute = routingTable.GetRouteFor(typeof(OtherMessageType));
            var messageWithoutNamespaceRoute = routingTable.GetRouteFor(typeof(MessageWithoutNamespace));

            Assert.That(someMessageRoute, Is.Not.Null);
            Assert.That(otherMessageRoute, Is.Not.Null);
            Assert.That(messageWithoutNamespaceRoute, Is.Not.Null);
        }
        public void Should_register_all_types_in_assembly_when_not_specifying_namespace()
        {
            var routingSettings = new RoutingSettings<MessageDrivenTransportDefinition>(new SettingsHolder());
            routingSettings.RegisterPublisher(Assembly.GetExecutingAssembly(), "someAddress");

            var publishers = ApplyPublisherRegistrations(routingSettings);

            var result1 = publishers.GetPublisherFor(typeof(BaseMessage)).SingleOrDefault();
            var result2 = publishers.GetPublisherFor(typeof(SubMessage)).SingleOrDefault();
            var result3 = publishers.GetPublisherFor(typeof(EventWithoutNamespace)).SingleOrDefault();
            var result4 = publishers.GetPublisherFor(typeof(IMessageInterface)).SingleOrDefault();

            Assert.IsNotNull(result1);
            Assert.IsNotNull(result2);
            Assert.IsNotNull(result3);
            Assert.IsNotNull(result4);
        }
Exemplo n.º 9
0
 public static void RegisterPublisher(this RoutingSettings <SqlServerTransport> routingSettings, Assembly assembly, string @namespace, string publisherEndpoint)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Instructs the endpoint configuration to connect to a designated router. A single endpoint can connect to a single router.
 /// </summary>
 /// <param name="routingSettings">Routing settings.</param>
 /// <param name="routerAddress">Transport address of router's interface.</param>
 public static RouterConnectionSettings ConnectToRouter(this RoutingSettings routingSettings, string routerAddress)
 {
     return(ConnectToRouterImpl(routingSettings, routerAddress, false, false));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Sets a distribution strategy for a given endpoint.
 /// </summary>
 /// <param name="config">Config object.</param>
 /// <param name="distributionStrategy">The instance of a distribution strategy.</param>
 public static void SetMessageDistributionStrategy(this RoutingSettings <MsmqTransport> config, DistributionStrategy distributionStrategy)
 {
     Guard.AgainstNull(nameof(distributionStrategy), distributionStrategy);
     config.Settings.GetOrCreate <List <DistributionStrategy> >().Add(distributionStrategy);
 }
Exemplo n.º 12
0
 static UnicastRoutingTable ApplyConfiguredRoutes(RoutingSettings routingSettings)
 {
     var routingTable = new UnicastRoutingTable();
     var configuredRoutes = routingSettings.Settings.GetOrDefault<ConfiguredUnicastRoutes>();
     configuredRoutes?.Apply(routingTable, new Conventions());
     return routingTable;
 }
 internal AzureStorageQueueTransportLegacySettings(AzureStorageQueueTransport transport, RoutingSettings <AzureStorageQueueTransport> routing)
     : base(transport, routing)
 {
 }
Exemplo n.º 14
0
 /// <summary>
 /// Returns the configuration options for the file based instance mapping file.
 /// </summary>
 /// <param name="config">MSMQ Transport configuration object.</param>
 public static InstanceMappingFileSettings InstanceMappingFile(this RoutingSettings <MsmqTransport> config)
 {
     Guard.AgainstNull(nameof(config), config);
     return(new InstanceMappingFileSettings(config.GetSettings()));
 }
Exemplo n.º 15
0
        public void WhenRoutingAssemblyWithNamespaceToEndpointAndSpecifyingEmptyNamespace_ShouldOnlyConfigureMessagesWithinEmptyNamespace(string emptyNamespace)
        {
            var routingSettings = new RoutingSettings(new SettingsHolder());
            routingSettings.RouteToEndpoint(Assembly.GetExecutingAssembly(), emptyNamespace, "destination");

            var routingTable = ApplyConfiguredRoutes(routingSettings);

            var someMessageRoute = routingTable.GetRouteFor(typeof(SomeMessageType));
            var otherMessageRoute = routingTable.GetRouteFor(typeof(OtherMessageType));
            var messageWithoutNamespaceRoute = routingTable.GetRouteFor(typeof(MessageWithoutNamespace));

            Assert.That(someMessageRoute, Is.Null);
            Assert.That(otherMessageRoute, Is.Null);
            Assert.That(messageWithoutNamespaceRoute, Is.Not.Null);
        }
 internal MsmqTransportSettings(MsmqTransport transport, RoutingSettings <MsmqTransport> routing)
     : base(transport, routing)
 {
 }
Exemplo n.º 17
0
 /// <summary>
 /// Disables the ability to publish events. This removes the need to provide a subscription storage option. The endpoint can still subscribe to events but isn't allowed to publish its events.
 /// </summary>
 public static void DisablePublishing <T>(this RoutingSettings <T> routingSettings) where T : TransportDefinition, IMessageDrivenSubscriptionTransport
 {
     routingSettings.Settings.Set(MessageDrivenSubscriptions.EnablePublishingSettingsKey, false);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Returns the configuration options for the file based instance mapping file.
 /// </summary>
 public static InstanceMappingFileSettings InstanceMappingFile(this RoutingSettings <MsmqTransport> config)
 {
     return(new InstanceMappingFileSettings(config.Settings));
 }
 static Publishers ApplyPublisherRegistrations(RoutingSettings<MessageDrivenTransportDefinition> routingSettings)
 {
     var publishers = new Publishers();
     var registrations = routingSettings.Settings.Get<ConfiguredPublishers>();
     registrations.Apply(publishers, new Conventions(), true);
     return publishers;
 }
 /// <summary>
 /// Instructs the endpoint configuration to connect to a designated router. A single endpoint can connect to a single router.
 /// </summary>
 /// <param name="routingSettings">Routing settings.</param>
 /// <param name="routerAddress">Transport address of router's interface.</param>
 /// <param name="enableAutoSubscribe">Enable automatic subscription for this router. If enabled, the endpoint will ask the router to subscribe to all events handled by this endpoint. The subscription will only work if the other side of the router uses native PubSub transport.</param>
 /// <param name="enableAutoPublish">Enable automatic publication forwarding of all published messages to the router.</param>
 public static RouterConnectionSettings ConnectToRouter(this RoutingSettings routingSettings, string routerAddress, bool enableAutoSubscribe, bool enableAutoPublish)
 {
     return(ConnectToRouterImpl(routingSettings, routerAddress, enableAutoSubscribe, enableAutoPublish));
 }
Exemplo n.º 21
0
 public static void RegisterPublisher(this RoutingSettings <SqlServerTransport> routingSettings, Type eventType, string publisherEndpoint)
 {
     throw new NotImplementedException();
 }