/// <summary>
        /// Configures a Turnout on the receive endpoint, which executes a long-running job and supervises the job until it
        /// completes.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="busFactoryConfigurator">The bus factory configuration to use a separate endpoint for the control traffic</param>
        /// <param name="queueName"></param>
        /// <param name="configure"></param>
        /// <param name="host"></param>
        public static void TurnoutEndpoint <T>(this IServiceBusBusFactoryConfigurator busFactoryConfigurator, IServiceBusHost host, string queueName,
                                               Action <ITurnoutServiceConfigurator <T> > configure)
            where T : class
        {
            string expiredQueueName = $"{queueName}-expired";

            // configure the message expiration endpoint, so it's available at startup
            busFactoryConfigurator.ReceiveEndpoint(host, expiredQueueName, expiredEndpointConfigurator =>
            {
                expiredEndpointConfigurator.SubscribeMessageTopics = false;

                // configure the turnout management endpoint
                var temporaryQueueName = host.GetTemporaryQueueName("turnout-");
                busFactoryConfigurator.ReceiveEndpoint(host, temporaryQueueName, turnoutEndpointConfigurator =>
                {
                    turnoutEndpointConfigurator.PrefetchCount          = 100;
                    turnoutEndpointConfigurator.EnableExpress          = true;
                    turnoutEndpointConfigurator.SubscribeMessageTopics = false;

                    turnoutEndpointConfigurator.EnableDeadLetteringOnMessageExpiration = true;
                    turnoutEndpointConfigurator.ForwardDeadLetteredMessagesTo          = expiredQueueName;

                    turnoutEndpointConfigurator.AutoDeleteOnIdle = TimeSpan.FromMinutes(5);

                    // configure the input queue endpoint
                    busFactoryConfigurator.ReceiveEndpoint(host, queueName, commandEndpointConfigurator =>
                    {
                        commandEndpointConfigurator.SubscribeMessageTopics = false;

                        commandEndpointConfigurator.ConfigureTurnoutEndpoints(busFactoryConfigurator, turnoutEndpointConfigurator, expiredEndpointConfigurator,
                                                                              configure);
                    });
                });
            });
        }
示例#2
0
        /// <summary>
        /// Creates a request client that uses the bus to publish a request.
        /// </summary>
        /// <typeparam name="TRequest">The request type</typeparam>
        /// <typeparam name="TResponse">The response type</typeparam>
        /// <param name="timeout">The timeout before the request is cancelled</param>
        /// <param name="callback">Callback when the request is sent</param>
        /// <param name="ttl">The time that the request will live for</param>
        /// <param name="host"></param>
        /// <param name="publishEndpoint"></param>
        /// <returns></returns>
        public static async Task <IRequestClient <TRequest, TResponse> > CreatePublishRequestClient <TRequest, TResponse>(this IServiceBusHost host,
                                                                                                                          IPublishEndpoint publishEndpoint, TimeSpan timeout, TimeSpan?ttl = default(TimeSpan?), Action <SendContext <TRequest> > callback = null)
            where TRequest : class
            where TResponse : class
        {
            var endpoint = await host.ConnectReceiveEndpoint(host.GetTemporaryQueueName("response")).ConfigureAwait(false);

            var ready = await endpoint.Ready.ConfigureAwait(false);

            return(new PublishRequestClient <TRequest, TResponse>(publishEndpoint, ready.ReceiveEndpoint, ready.InputAddress, timeout, ttl, callback));
        }
        /// <summary>
        /// Declare a ReceiveEndpoint using a unique generated queue name. This queue defaults to auto-delete
        /// and non-durable. By default all services bus instances include a default receiveEndpoint that is
        /// of this type (created automatically upon the first receiver binding).
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="host"></param>
        /// <param name="configure"></param>
        public static void ReceiveEndpoint(this IServiceBusBusFactoryConfigurator configurator, IServiceBusHost host,
                                           Action <IServiceBusReceiveEndpointConfigurator> configure)
        {
            var queueName = host.GetTemporaryQueueName("endpoint");

            configurator.ReceiveEndpoint(host, queueName, x =>
            {
                x.AutoDeleteOnIdle = TimeSpan.FromMinutes(5);
                x.EnableExpress    = true;

                configure(x);
            });
        }
示例#4
0
        /// <summary>
        /// Creates a management endpoint which can be used by controllable filters on a bus intance
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="host">The service bus host</param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static IManagementEndpointConfigurator ManagementEndpoint(this IServiceBusBusFactoryConfigurator configurator,
                                                                         IServiceBusHost host, Action <IReceiveEndpointConfigurator> configure = null)
        {
            var queueName = host.GetTemporaryQueueName("manage-");

            var specification = new ServiceBusReceiveEndpointSpecification(host, queueName)
            {
                AutoDeleteOnIdle = TimeSpan.FromMinutes(5),
                EnableExpress    = true,
            };

            configure?.Invoke(specification);

            configurator.AddReceiveEndpointSpecification(specification);

            var managementEndpointConfigurator = new ManagementEndpointConfigurator(specification);

            return(managementEndpointConfigurator);
        }
        /// <summary>
        /// Creates a management endpoint which can be used by controllable filters on a bus intance
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="host">The service bus host</param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static IManagementEndpointConfigurator ManagementEndpoint(this IServiceBusBusFactoryConfigurator configurator,
                                                                         IServiceBusHost host, Action <IReceiveEndpointConfigurator> configure = null)
        {
            var queueName = host.GetTemporaryQueueName("manage-");

            IServiceBusReceiveEndpointConfigurator specification = null;

            configurator.ReceiveEndpoint(host, queueName, x =>
            {
                x.AutoDeleteOnIdle = TimeSpan.FromMinutes(5);
                x.EnableExpress    = true;

                configure?.Invoke(x);

                specification = x;
            });

            return(new ManagementEndpointConfigurator(specification));
        }
        /// <summary>
        /// Declare a ReceiveEndpoint using a unique generated queue name. This queue defaults to auto-delete
        /// and non-durable. By default all services bus instances include a default receiveEndpoint that is
        /// of this type (created automatically upon the first receiver binding).
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="host"></param>
        /// <param name="configure"></param>
        public static void ReceiveEndpoint(this IServiceBusBusFactoryConfigurator configurator, IServiceBusHost host,
            Action<IServiceBusReceiveEndpointConfigurator> configure)
        {
            var queueName = host.GetTemporaryQueueName("endpoint");

            configurator.ReceiveEndpoint(host, queueName, x =>
            {
                x.AutoDeleteOnIdle = TimeSpan.FromMinutes(5);
                x.EnableExpress = true;

                configure(x);
            });
        }
        /// <summary>
        /// Creates a management endpoint which can be used by controllable filters on a bus intance
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="host">The service bus host</param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static IManagementEndpointConfigurator ManagementEndpoint(this IServiceBusBusFactoryConfigurator configurator,
            IServiceBusHost host, Action<IReceiveEndpointConfigurator> configure = null)
        {
            var queueName = host.GetTemporaryQueueName("manage-");

            var specification = new ServiceBusReceiveEndpointSpecification(host, queueName)
            {
                AutoDeleteOnIdle = TimeSpan.FromMinutes(5),
                EnableExpress = true,
            };

            configure?.Invoke(specification);

            configurator.AddReceiveEndpointSpecification(specification);

            var managementEndpointConfigurator = new ManagementEndpointConfigurator(specification);

            return managementEndpointConfigurator;
        }