How to use MassTransit.QuartzService?

616 views
Skip to first unread message

Noel Kwok

unread,
Jan 14, 2015, 2:02:45 AM1/14/15
to masstrans...@googlegroups.com
Hi,everyone! I'm the newer of MassTransit.I want use the MassTransit.QuartzService to schedulemessage. I have compling the source code of MassTransit.QuartzService and run it in the console.
this is the config file of MassTransit.QuartzService
  <appSettings>
    <add key="Scheme" value="msmq" />
    <add key="MSMQHost" value="localhost" />
    <add key="RabbitMQHost" value="localhost" />
    <add key="RabbitMQVirtualHost" value="" />
    <add key="RabbitMQUsername" value="guest" />
    <add key="RabbitMQPassword" value="guest" />
    <add key="RabbitMQOptions" value="" />
    <add key="ControlQueueName" value="masstransit_quartz_scheduler" />
    <add key="ConsumerLimit" value="1" />
  </appSettings>

this is my sample,but it doesn't work
Bus.Initialize(cfg =>
            {
                cfg.UseMsmq();
                cfg.UseMulticastSubscriptionClient();
                cfg.UseJsonSerializer();
                cfg.ReceiveFrom("msmq://localhost/masstransit_quartz_scheduler");
                cfg.BeforeConsumingMessage(() => Console.WriteLine(DateTime.Now));
                cfg.Subscribe(subs =>
                {
                    subs.Handler<ScheduledMessage>(msg => Console.WriteLine("Message received!"));
                });
            });

      
            Bus.Instance.ScheduleMessage<ScheduledMessage>(DateTime.Now.AddSeconds(5), new ScheduledMessage() { Values = "msg"});
            Console.ReadKey();

I'm in lost,I can't found any sample of MassTransit.QuartzService about how to use it.

Chris Patterson

unread,
Jan 15, 2015, 11:49:33 AM1/15/15
to masstrans...@googlegroups.com
You should create a handler for your own message type:


Then schedule yourself a copy of that message:


It looks like you're using the ScheduledMessage type, which is returned from ScheduleMessage and contains the schedule message details (unless you've created your own).

It also seems like you're using the same queue for your Bus test and the quartz scheduler, which is a no-no. All buses must have their own queues. So change your sample to use a different queue name.


--
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/6f2c6a8b-325f-4dc4-b1f8-1c56e04172fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages