protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            configurator.UseDelayedRedelivery(r => r.Intervals(100, 200));

            _consumer = new Consumer();
            configurator.Consumer(() => _consumer);
        }
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            _count = 0;

            _received = GetTask <ConsumeContext <PingMessage> >();

            configurator.Handler <PingMessage>(async context =>
            {
                if (_timer == null)
                {
                    _timer = Stopwatch.StartNew();
                }

                if (_count++ < 2)
                {
                    Console.WriteLine("{0} now is not a good time", DateTime.UtcNow);

                    await context.Defer(TimeSpan.FromMilliseconds(1000), (consumeContext, sendContext) =>
                    {
                        _hit = true;
                    });

                    return;
                }

                _timer.Stop();

                Console.WriteLine("{0} okay, now is good (retried {1} times)", DateTime.UtcNow, context.Headers.Get("MT-Redelivery-Count", default(int?)));

                // okay, ready.
                _receivedTimeSpan = _timer.Elapsed;
                _received.TrySetResult(context);
            });
        }
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            _count = 0;

            _received = GetTask <ConsumeContext <PingMessage> >();

            configurator.Handler <PingMessage>(context =>
            {
                if (_timer == null)
                {
                    _timer = Stopwatch.StartNew();
                }

                if (_count++ < 2)
                {
                    Console.WriteLine("{0} now is not a good time", DateTime.UtcNow);
                    throw new IntentionalTestException("I'm so not ready for this jelly.");
                }

                _timer.Stop();

                Console.WriteLine("{0} okay, now is good (retried {1} times)", DateTime.UtcNow, context.Headers.Get("MT-Redelivery-Count", default(int?)));

                // okay, ready.
                _receivedTimeSpan = _timer.Elapsed;
                _received.TrySetResult(context);

                return(TaskUtil.Completed);
            }, x => x.UseDelayedRedelivery(r => r.Intervals(1000, 2000)));
        }
Beispiel #4
0
 protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
 {
     Handler <PingMessage>(configurator, context =>
     {
         throw new SerializationException("This is fine, forcing death");
     });
 }
        /// <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 IActiveMqBusFactoryConfigurator configurator,
                                                                         IActiveMqHost host, Action <IActiveMqReceiveEndpointConfigurator> configure = null)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            var queueName = host.Topology.CreateTemporaryQueueName("manage-");

            IActiveMqReceiveEndpointConfigurator specification = null;

            configurator.ReceiveEndpoint(host, queueName, x =>
            {
                x.AutoDelete = true;
                x.Durable    = false;

                configure?.Invoke(x);

                specification = x;
            });

            var managementEndpointConfigurator = new ManagementEndpointConfigurator(specification);

            return(managementEndpointConfigurator);
        }
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            configurator.UseDelayedRedelivery(r => r.Interval(1, TimeSpan.FromMilliseconds(100)));
            configurator.UseRetry(r => r.Interval(1, TimeSpan.FromMilliseconds(100)));
            configurator.UseInMemoryOutbox();

            configurator.Consumer <TestHandler>();
        }
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            configurator.UseDelayedRedelivery(r => r.Intervals(100));
            configurator.UseMessageRetry(x => x.Immediate(2));

            Consumer.PingCount = 0;

            configurator.Consumer(() => new Consumer());
        }
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            _first = Handler <FirstMessage>(configurator, async context =>
            {
                await context.Send(InputQueueAddress, new SecondMessage());
            });

            _second = Handled <SecondMessage>(configurator);
        }
Beispiel #9
0
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            base.ConfigureActiveMqReceiveEndpoint(configurator);

            _consumer = new ReconnectConsumer(TestTimeout);

            _consumer.Configure(configurator);

            configurator.Handler <PingMessage>(context => context.RespondAsync(new PongMessage(context.Message.CorrelationId)));
        }
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            configurator.ConfigureConsumeTopology = false;

            configurator.Bind("VirtualTopic.private");

            _handler = Handled <PrivateMessage>(configurator);

            Handled <PingMessage>(configurator);
        }
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            _first = Handler <FirstMessage>(configurator, async context =>
            {
                await context.SchedulePublish(DateTime.Now, new SecondMessage());

                await context.ReceiveContext.ReceiveCompleted;
            });

            _second = Handled <SecondMessage>(configurator);
        }
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            _first = Handler <FirstMessage>(configurator, async context =>
            {
                await context.ScheduleSend(TimeSpan.FromSeconds(3), new SecondMessage());

                await context.ReceiveContext.ReceiveCompleted;
            });

            _second = Handled <SecondMessage>(configurator);
        }
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            _count = 0;

            configurator.Handler <PingMessage>(context =>
            {
                Interlocked.Increment(ref _count);

                throw new IntentionalTestException();
            }, x => x.UseDelayedRedelivery(r => r.Intervals(100, 200)));
        }
        /// <summary>
        /// For all configured messages type (handlers, consumers, and sagas), configures delayed redelivery using the retry configuration specified.
        /// Redelivery is configured once for each message type, and is added prior to the consumer factory or saga repository in the pipeline.
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="configureRetry"></param>
        public static void UseDelayedRedelivery(this IActiveMqReceiveEndpointConfigurator configurator, Action <IRetryConfigurator> configureRetry)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            if (configureRetry == null)
            {
                throw new ArgumentNullException(nameof(configureRetry));
            }

            var observer = new DelayedExchangeRedeliveryConfigurationObserver(configurator, configureRetry);
        }
Beispiel #15
0
        /// <summary>
        /// We may want to have a builder/endpoint context that could store things like management endpoint, etc. to configure
        /// filters and add configuration interfaces for things like concurrency limit and prefetch count
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="definition"></param>
        /// <param name="configure">The callback to invoke after the definition configuration has been applied</param>
        internal static void Apply(this IActiveMqReceiveEndpointConfigurator configurator, IEndpointDefinition definition,
                                   Action <IActiveMqReceiveEndpointConfigurator> configure = null)
        {
            if (definition.IsTemporary)
            {
                configurator.AutoDelete = true;
                configurator.Durable    = false;
            }

            if (definition.ConcurrentMessageLimit.HasValue)
            {
                configurator.UseConcurrencyLimit(definition.ConcurrentMessageLimit.Value);
            }

            definition.Configure(configurator);

            configure?.Invoke(configurator);
        }
Beispiel #16
0
        /// <summary>
        /// We may want to have a builder/endpoint context that could store things like management endpoint, etc. to configure
        /// filters and add configuration interfaces for things like concurrency limit and prefetch count
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="definition"></param>
        /// <param name="configure">The callback to invoke after the definition configuration has been applied</param>
        internal static void Apply(this IActiveMqReceiveEndpointConfigurator configurator, IEndpointDefinition definition,
                                   Action <IActiveMqReceiveEndpointConfigurator> configure = null)
        {
            if (definition.IsTemporary)
            {
                configurator.AutoDelete = true;
                configurator.Durable    = false;
            }

            if (definition.PrefetchCount.HasValue)
            {
                configurator.PrefetchCount = (ushort)definition.PrefetchCount.Value;
            }

            if (definition.ConcurrentMessageLimit.HasValue)
            {
                var concurrentMessageLimit = definition.ConcurrentMessageLimit.Value;

                // if there is a prefetchCount, and it is greater than the concurrent message limit, we need a filter
                if (!definition.PrefetchCount.HasValue || definition.PrefetchCount.Value > concurrentMessageLimit)
                {
                    configurator.UseConcurrencyLimit(concurrentMessageLimit);

                    // we should determine a good value to use based upon the concurrent message limit
                    if (definition.PrefetchCount.HasValue == false)
                    {
                        var calculatedPrefetchCount = concurrentMessageLimit * 12 / 10;

                        configurator.PrefetchCount = (ushort)calculatedPrefetchCount;
                    }
                }
            }

            definition.Configure(configurator);

            configure?.Invoke(configurator);
        }
Beispiel #17
0
 private static void Consumer <T>(IActiveMqReceiveEndpointConfigurator conf, IServiceProvider context) where T : class, IConsumer, new()
 {
     conf.Consumer <T>(context);
 }
 protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
 {
     Handled <SubmitOrder>(configurator);
 }
 protected virtual void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
 {
 }
Beispiel #20
0
        protected override void ConfigureActiveMqReceiveEndpoint(IActiveMqReceiveEndpointConfigurator configurator)
        {
            configurator.PrefetchCount = 1;

            configurator.Consumer <BadConsumer>();
        }