public static void EnableWindowsPerformanceCounters(this IBusFactoryConfigurator configurator)
        {
            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));

            var specification = new PerformanceCounterBusFactorySpecification(new WindowsCounterFactory());
            configurator.AddBusFactorySpecification(specification);
        }
        public static void EnableStatsdPerformanceCounters(this IBusFactoryConfigurator configurator, Action<StatsDConfiguration> action)
        {
            var statsDConfiguration = StatsDConfiguration.Defaults();
            action(statsDConfiguration);

            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));

            var specification = new PerformanceCounterBusFactorySpecification(new StatsDCounterFactory(statsDConfiguration));
            configurator.AddBusFactorySpecification(specification);
        }
        public static IManagementEndpointConfigurator ManagementEndpoint(this IInMemoryBusFactoryConfigurator configurator,
            Action<IReceiveEndpointConfigurator> configure = null)
        {
            var queueName = configurator.GetTemporaryQueueName("manage-");

            var endpointConfigurator = new InMemoryReceiveEndpointConfigurator(queueName)
            {
                TransportConcurrencyLimit = 1
            };

            configure?.Invoke(endpointConfigurator);

            configurator.AddBusFactorySpecification(endpointConfigurator);

            var managementEndpointConfigurator = new ManagementEndpointConfigurator(endpointConfigurator);

            return managementEndpointConfigurator;
        }
        public static void UseInMemoryScheduler(this IBusFactoryConfigurator configurator)
        {
            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));

            ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
            var scheduler = schedulerFactory.GetScheduler();

            var specification = new InMemorySchedulerBusFactorySpecification(scheduler);
            configurator.AddBusFactorySpecification(specification);

            configurator.ReceiveEndpoint("quartz", e =>
            {
                configurator.UseMessageScheduler(e.InputAddress);

                e.Consumer(() => new ScheduleMessageConsumer(scheduler));
                e.Consumer(() => new CancelScheduledMessageConsumer(scheduler));
            });
        }
        public static void UseInMemoryScheduler(this IBusFactoryConfigurator configurator)
        {
            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));

            ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
            var scheduler = schedulerFactory.GetScheduler();

            configurator.ReceiveEndpoint("quartz", e =>
            {
                var partitioner = configurator.CreatePartitioner(16);

                e.Consumer(() => new ScheduleMessageConsumer(scheduler), x =>
                    x.Message<ScheduleMessage>(m => m.UsePartitioner(partitioner, p => p.Message.CorrelationId)));
                e.Consumer(() => new CancelScheduledMessageConsumer(scheduler), x =>
                    x.Message<CancelScheduledMessage>(m => m.UsePartitioner(partitioner, p => p.Message.TokenId)));

                configurator.UseMessageScheduler(e.InputAddress);

                var specification = new SchedulerBusFactorySpecification(scheduler, e.InputAddress);
                configurator.AddBusFactorySpecification(specification);
            });
        }
 /// <summary>
 /// Add support for the binary message deserializer to the bus. This serializer is not supported
 /// by default.
 /// </summary>
 /// <param name="configurator"></param>
 /// <returns></returns>
 public static void SupportBinaryMessageDeserializer(this IBusFactoryConfigurator configurator)
 {
     configurator.AddBusFactorySpecification(new SupportMessageDeserializerBusFactorySpecification(
         BinaryMessageSerializer.BinaryContentType, (s, p) => new BinaryMessageDeserializer(JsonMessageSerializer.Serializer, s, p)));
 }
        /// <summary>
        /// Serialize message using the .NET binary formatter (also adds support for the binary deserializer)
        /// </summary>
        /// <param name="configurator"></param>
        public static void UseBinarySerializer(this IBusFactoryConfigurator configurator)
        {
            configurator.AddBusFactorySpecification(
                new SetMessageSerializerBusFactorySpecification<BinaryMessageSerializer>());

            configurator.SupportBinaryMessageDeserializer();
        }
 /// <summary>
 /// Serialize messages using the XML message serializer
 /// </summary>
 /// <param name="configurator"></param>
 public static void UseXmlSerializer(this IBusFactoryConfigurator configurator)
 {
     configurator.AddBusFactorySpecification(
         new SetMessageSerializerBusFactorySpecification<XmlMessageSerializer>());
 }
 public static void UseEncryptedSerializer(this IBusFactoryConfigurator configurator, ICryptoStreamProvider streamProvider)
 {
     configurator.AddBusFactorySpecification(new EncryptedMessageSerializerBusFactorySpecification(streamProvider));
 }
 /// <summary>
 /// Add support for the binary message deserializer to the bus. This serializer is not supported
 /// by default.
 /// </summary>
 /// <param name="configurator"></param>
 /// <returns></returns>
 public static void SupportProtocolBuffersMessageDeserializer(this IBusFactoryConfigurator configurator)
 {
     configurator.AddBusFactorySpecification(new SupportMessageDeserializerBusFactorySpecification(
         ProtocolBuffersMessageSerializer.ProtocolBuffersContentType, () => new ProtocolBuffersMessageDeserializer()));
 }
        /// <summary>
        /// Serialize messages using the BSON message serializer
        /// </summary>
        /// <param name="configurator"></param>
        public static void UseProtocolBuffersSerializer(this IBusFactoryConfigurator configurator)
        {
            configurator.AddBusFactorySpecification(new SetMessageSerializerBusFactorySpecification<ProtocolBuffersMessageSerializer>());

            SupportProtocolBuffersMessageDeserializer(configurator);
        }
        /// <summary>
        /// Registers a management endpoint on the bus, which can be used to control
        /// filters and other management control points on the bus.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="host">The host where the endpoint is to be created</param>
        /// <param name="configure">Configure additional values of the underlying receive endpoint</param>
        /// <returns></returns>
        public static IManagementEndpointConfigurator ManagementEndpoint(this IRabbitMqBusFactoryConfigurator configurator,
            IRabbitMqHost host, Action<IRabbitMqReceiveEndpointConfigurator> configure = null)
        {
            if (configurator == null)
                throw new ArgumentNullException(nameof(configurator));
            if (host == null)
                throw new ArgumentNullException(nameof(host));

            var queueName = configurator.GetTemporaryQueueName("manage-");

            var endpointConfigurator = new RabbitMqReceiveEndpointConfigurator(host, queueName);

            configure?.Invoke(endpointConfigurator);

            configurator.AddBusFactorySpecification(endpointConfigurator);

            var managementEndpointConfigurator = new ManagementEndpointConfigurator(endpointConfigurator);

            return managementEndpointConfigurator;
        }