MassTransit Schedule message with quartz not working

1,709 views
Skip to first unread message

Tomer Yoskovich

unread,
Dec 23, 2015, 11:57:06 AM12/23/15
to masstransit-discuss
Hello,

I am trying to use MassTransit with quartz (3.0.17), from the automatonymous saga I issue a .Schedule()

What could be the causes of the following log that I saw in RabbitMQ?

MT-Fault-Message:
The scheduler context could not be retrieved.

MT-Fault-StackTrace:
at Automatonymous.Activities.ScheduleActivity`3.<Automatonymous-Activity<TInstance\,TData>-Execute>d__6.MoveNext() 
at Automatonymous.Activities.DataConverterActivity`2.<Automatonymous-Activity<TInstance>-Execute>d__4`1.MoveNext() 
at Automatonymous.Behaviors.ActivityBehavior`1.<Automatonymous-Behavior<TInstance>-Execute>d__5`1.MoveNext()

Chris Patterson

unread,
Dec 23, 2015, 1:03:59 PM12/23/15
to masstrans...@googlegroups.com
You need to have the UseMessageScheduler configuration to specify the address where Quartz is running. 



__
Chris Patterson




--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/8663bac8-a266-4425-b6fe-bce8e7bd4478%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tomer Yoskovich

unread,
Dec 24, 2015, 7:01:40 AM12/24/15
to masstransit-discuss
This is the configuration that I'm having

Process #1 contains quartz itself, and has the following configured when connecting to the bus:
 
sbc.ReceiveEndpoint(host, ConfigurationManager.AppSettings["rabbitmq://localhost/quartz"], e =>
                    {
                        sbc.UseMessageScheduler(e.InputAddress);

                        e.Consumer(() => new ScheduleMessageConsumer(scheduler));
                        e.Consumer(() => new CancelScheduledMessageConsumer(scheduler));
                    });

Process #2 has the following:
sbc.UseMessageScheduler(new Uri("rabbitmq://localhost/quartz"));

am I missing anything above?


On Wednesday, December 23, 2015 at 8:03:59 PM UTC+2, Chris Patterson wrote:
You need to have the UseMessageScheduler configuration to specify the address where Quartz is running. 



__
Chris Patterson




On Wed, Dec 23, 2015 at 8:57 AM -0800, "Tomer Yoskovich" <to...@yoskovich.com> wrote:

Hello,

I am trying to use MassTransit with quartz (3.0.17), from the automatonymous saga I issue a .Schedule()

What could be the causes of the following log that I saw in RabbitMQ?

MT-Fault-Message:
The scheduler context could not be retrieved.

MT-Fault-StackTrace:
at Automatonymous.Activities.ScheduleActivity`3.<Automatonymous-Activity<TInstance\,TData>-Execute>d__6.MoveNext() 
at Automatonymous.Activities.DataConverterActivity`2.<Automatonymous-Activity<TInstance>-Execute>d__4`1.MoveNext() 
at Automatonymous.Behaviors.ActivityBehavior`1.<Automatonymous-Behavior<TInstance>-Execute>d__5`1.MoveNext()

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Chris Patterson

unread,
Dec 24, 2015, 9:00:51 AM12/24/15
to masstrans...@googlegroups.com
That looks correct. Is this working for you or are you still seeing issues? 




To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Alexey Zimarev

unread,
Aug 11, 2016, 10:20:17 AM8/11/16
to masstransit-discuss
I have this issue in my saga. I have two states where I schedule messages - in "Initial" and in some "During". The one in "Initial" works fine but the one in "During" fails with MassTransit.ContextException: The scheduler context could not be retrieved

Alexey Zimarev

unread,
Aug 11, 2016, 10:34:20 AM8/11/16
to masstransit-discuss
I am actually wrong, I have one service where it works fine in "During.When" and another one where it only works in "Initially" and then fails in "During.When". It seems to be non deterministic issue, but I know for sure that scheduling context is configured since it works in one place but does not work in another. Both Schedules are configured identically and this is the same state machine.

Chris Patterson

unread,
Aug 11, 2016, 12:14:19 PM8/11/16
to masstrans...@googlegroups.com
Are both services using the same saga? I'm not sure I understand, you have the saga on multiple endpoints?

A log with a call stack of the error might lend some input, as well as a probe output in JSON format to see how the pipeline is configured.



On Thu, Aug 11, 2016 at 7:34 AM, Alexey Zimarev <azim...@gmail.com> wrote:
I am actually wrong, I have one service where it works fine in "During.When" and another one where it only works in "Initially" and then fails in "During.When". It seems to be non deterministic issue, but I know for sure that scheduling context is configured since it works in one place but does not work in another. Both Schedules are configured identically and this is the same state machine.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Alexey Zimarev

unread,
Aug 11, 2016, 12:57:17 PM8/11/16
to masstransit-discuss
No, this is not what I mean. I have two completely different services that use saga state machines. Both use scheduling.
In one service scheduling always works from the saga.
In another service, Schedule call works fine from Initially and then another Schedule fails with this "no scheduling context" in the same saga, later in the flow.

Chris Patterson

unread,
Aug 11, 2016, 5:18:36 PM8/11/16
to masstrans...@googlegroups.com
Okay, yeah, that's weird. Can you give me a section of the events for the state machine to try to reproduce? Sounds like an overload that isn't setup properly.

You can email or private gist if needed directly to me.


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.

Tomasz Zaba

unread,
Nov 24, 2016, 2:39:32 PM11/24/16
to masstransit-discuss
Hi Guys,

Any update with this problem ?
I am struggling with more like the same, Sample saga work like a charm but the one with business logic freezes on Schedule with the same message

The scheduler context could not be retrieved.

W dniu czwartek, 11 sierpnia 2016 23:18:36 UTC+2 użytkownik Chris Patterson napisał:
Okay, yeah, that's weird. Can you give me a section of the events for the state machine to try to reproduce? Sounds like an overload that isn't setup properly.

You can email or private gist if needed directly to me.

On Thu, Aug 11, 2016 at 9:57 AM, Alexey Zimarev <azim...@gmail.com> wrote:
No, this is not what I mean. I have two completely different services that use saga state machines. Both use scheduling.
In one service scheduling always works from the saga.
In another service, Schedule call works fine from Initially and then another Schedule fails with this "no scheduling context" in the same saga, later in the flow.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Nov 24, 2016, 6:48:55 PM11/24/16
to masstrans...@googlegroups.com
You're missing the scheduler configuration on the bus. Try .UseMessageScheduler()



__
Chris Patterson




To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Tomasz Zaba

unread,
Nov 25, 2016, 3:15:03 AM11/25/16
to masstransit-discuss
Hi Chris,

My config for saga:

            builder.Register(c => {
                var scheduler = c.Resolve<IScheduler>();

                var busControl = MassTransit.Bus.Factory.CreateUsingRabbitMq(cfg => {
                    var host = cfg.Host(new Uri("rabbitmq://localhost/"), h => {
                        h.Username("guest");
                        h.Password("guest");
                    });

                    cfg.ReceiveEndpoint(host, "execution_dispatch_work_order_queue", ec => {
                        ec.LoadFrom(c);

                        ec.StateMachineSaga(c.Resolve<MassTransitStateMachine<DispatchState>>(), new InMemorySagaRepository<DispatchState>());
                    });

                    cfg.ReceiveEndpoint(host, "execution_dispatch_work_order_scheduler", ec => {
                        ec.UseMessageScheduler(ec.InputAddress);

                        ec.Consumer(() => new ScheduleMessageConsumer(scheduler));
                        ec.Consumer(() => new CancelScheduledMessageConsumer(scheduler));
                    });

                    cfg.UseNLog();
                });

                scheduler.JobFactory = new MassTransitJobFactory(busControl);

                return busControl;

Alexey Zimarev

unread,
Nov 25, 2016, 3:28:42 PM11/25/16
to masstransit-discuss
I think the last couple of messages went private.

What I wrote was that the scheduler configuration is incorrectly applied to the scheduler endpoint, when it should be either on the bus configuration scope or on the saga endpoint scope.

So instead of 
ec.UseMessageScheduler(ec.InputAddress);

it really should be
cfg.UseMessageScheduler(ec.InputAddress);

Chris Patterson

unread,
Nov 25, 2016, 8:39:38 PM11/25/16
to masstrans...@googlegroups.com
Alexey is right, you're only configuring it for that single endpoint, not the entire bus (all endpoints and hosts).

Also, look at this to see how you should properly be configured quartz to run on an endpoint.



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages