6

I would like to queue up messages to be processed, only after a given duration of time elapses (i.e., a minimum date/time for execution is met), and/or at processing time of a message, defer its execution to a later point in time (say some prerequisite checks are not met).

For example, an event happens which defines a process that needs to run no sooner than 1 hour from the time of the initial event.

Is there any built in/suggested model to orchestrate this using https://github.com/ServiceStack/ServiceStack/wiki/Messaging-and-Redis?

JesseP
  • 756
  • 1
  • 7
  • 23
  • 1
    Did you get this working, I'm looking at something similar? I was thinking of a scheduled task run every x seconds to poll the queue. – Neil Oct 02 '13 at 21:14
  • No, not exactly. It seems it isn't supported, and I was already experimenting with MassTransit, so I started using MassTransit with the Quartz integration (backed by MongoDB job store). Working great so far. :) – JesseP Oct 08 '13 at 19:16
  • Did you get anywhere Neil? I don't want to have to maintain another whole technology just to achieve this when it seems so close with Redis and ServiceStack. – richardwhatever Feb 10 '15 at 14:47
  • maybe @mythz has an opinion on this? – richardwhatever May 25 '15 at 07:47

2 Answers2

2

I would probably build this in a two step approach.

  1. Queue the Task into your Queueing system, which will process it into a persistence store: SQL Server, MongoDB, RavenDB.

  2. Have a service polling your "Queued" tasks for when they should be reinserted back into the Queue.

Probably the safest way, since you don't want to lose these jobs presumably.

If you use RabbitMQ instead of Redis you could use Dead Letter Queues to get the same behavior. Dead letter queues essentially are catchers for expired messages.

So you push your messages into a queue with no intention of processing them, and they have a specific expiration in minutes. When they expire they pop over into the queue that you will process out of. Pretty slick way to queue things for later.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Khalid Abuhakmeh
  • 10,709
  • 10
  • 52
  • 75
  • 2 step approach is what I was thinking was required as well. I already have that stuff built from my previous implementation, was just curious if i could rip it out or if i had to leave it. Thanks for the ideas. – JesseP Aug 29 '13 at 01:02
0

You could always use https://github.com/dominionenterprises/mongo-queue-csharp or https://github.com/dominionenterprises/mongo-queue-php or https://github.com/gaillard/mongo-queue-java which provides delayed messages and other uncommon features.

fields
  • 879
  • 2
  • 9
  • 19