Quartz MassTransit3 and SQL

179 views
Skip to first unread message

andy...@pmas.co.uk

unread,
Jan 8, 2016, 3:56:32 AM1/8/16
to masstransit-discuss
Hello all,

I've had a problem for the last day and I have no idea what i'm doing wrong, I setup a bus, setup a quartz scheduler using MSSQL as the datastore and send scheduled message. However the message never gets the Quartz tables and I have no error. No doubt I've setup something incorrect but no idea what

Create Scheduler

        public static class QuartzScheduler
    {
        public static IScheduler Create()
        {
            var quartzProperties = new NameValueCollection
            {
                {"quartz.scheduler.instanceName", Environment.MachineName},
                {"quartz.scheduler.instanceId", "bulkquote"},
                {"quartz.threadPool.threadCount", "10"},
                {"quartz.threadPool.threadPriority", "Normal"},
                {"quartz.scheduler.idleWaitTime", "5000"},
                {"quartz.jobStore.misfireThreshold", "60000"},
                {"quartz.jobStore.type", "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz"},
                {"quartz.jobStore.tablePrefix", "QRTZ_"}, 
                {"quartz.jobStore.clustered", "false"}, 
                {"quartz.jobStore.driverDelegateType", "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz"}, 
                {"quartz.jobStore.dataSource", "MySqlServerFullVersion"},
                {"quartz.dataSource.MySqlServerFullVersion.connectionString", ConfigurationManager.ConnectionStrings["QuartzConnectionString"].ConnectionString},
                {"quartz.dataSource.MySqlServerFullVersion.provider", "SqlServer-20"}
            };

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

            return scheduler;
        }
    }

Setup bus

                _scheduler = QuartzScheduler.Create();
                
                _bus = MassTransit.Bus.Factory.CreateUsingRabbitMq(configurator =>
                {
                    var host = configurator.Host(new Uri("rabbitmq://localhost/"), h =>
                    {
                        h.Username(RabbitUserName);
                        h.Password(RabbitPassword);
                    });
                    configurator.UseMessageScheduler(new Uri("rabbitmq://localhost/quartz"));
                    configurator.ReceiveEndpoint(host, "HomeRisks", endpointConfigurator =>
                    {
                        endpointConfigurator.PrefetchCount = MaxConcurrentThreads;
                        endpointConfigurator.Consumer(() => _container.Resolve<GetHomeQuoteBulkQuoteConsumer>());
                    });
                    configurator.ReceiveEndpoint(host, "MotorRisks", endpointConfigurator =>
                    {
                        endpointConfigurator.PrefetchCount = MaxConcurrentThreads;
                        endpointConfigurator.Consumer(() => _container.Resolve<GetMotorQuoteBulkQuoteConsumer>());
                    });
                });
                _bus.Start();
                _scheduler.JobFactory = new MassTransitJobFactory(_bus);
                _scheduler.Start();

Sending message to scheduler

                var schedulerEndpoint = await bus.GetSendEndpoint(new Uri("rabbitmq://localhost/quartz"));
         await schedulerEndpoint.ScheduleSend(new Uri("rabbitmq://localhost"), DateTime.Now.AddSeconds(60), message);

No thing enters the queue and I have no errors, I'm sure i't something I've overlooked anyone have any ideas?


Many thanks

Andy

Chris Patterson

unread,
Jan 8, 2016, 10:36:31 AM1/8/16
to masstrans...@googlegroups.com
The endpoint address passed to schedule send needs to be the full address of the queue to which the message should be sent. You currently just have local host which is the host address. Add the queue name to that which matches the receive endpoint and that should resolve the issue. 

__
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/c165620d-60d9-40cc-b8b2-a1ed8a9f2f0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

andy...@pmas.co.uk

unread,
Jan 8, 2016, 11:12:28 AM1/8/16
to masstransit-discuss
Hi Chris,

I tried that as well with the following and tried within a consumer none of it works :(

var schedulerEndpoint = await bus.GetSendEndpoint(new Uri("rabbitmq://localhost/quartz"));
await schedulerEndpoint.ScheduleSend(new Uri("rabbitmq://localhost/HomeRisks"), DateTime.Now.AddSeconds(5), message);

 Any other ideas?

Chris Patterson

unread,
Jan 8, 2016, 12:08:42 PM1/8/16
to masstrans...@googlegroups.com
Oh, you haven't registered the actual Quartz consumers. Take a look at this code snippet to see what needs to be done:


You'll need that receive endpoint and consumer setup, in your case you're creating the scheduler yourself and using SQL as a back end, but the requirements are the same.

--
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.

andy...@pmas.co.uk

unread,
Jan 8, 2016, 12:18:58 PM1/8/16
to masstransit-discuss
Superstar added the following

                    configurator.ReceiveEndpoint(host, "quartz", endpointConfigurator =>
                    {
                        configurator.UseMessageScheduler(endpointConfigurator.InputAddress);
                        endpointConfigurator.Consumer(() => new ScheduleMessageConsumer(_scheduler));
                        endpointConfigurator.Consumer(() => new CancelScheduledMessageConsumer(_scheduler));
                    });

Now my job queue is being populated, many thanks again Chris
 
Reply all
Reply to author
Forward
0 new messages