this sounds like a good candidate for a saga. here is one idea.

paymentsaga
 : Isagastate<paymentstate>
 : initializedby<submitpayment>
 : orchstrates<submitpaymentagain>
{
   public guid id {get;set;}
   public paymentstate state {get;set;} 
   public bool iscopmlete {get;set;}

   public void consume(submitpayment message)
   {
         var provider = paymentproviderfactory.create(message.paymenttype);
         if(provider.chargepayment(message...) == false)
         {
                state. failattempts = 1;
                var paymenttype = provider.getnextpaymentmethod(message...);
                bus.delaysend(datetime.now.addhours(4), new 
submitpaymentagain{paymenttype});
               return;
         }
         bus.send(new paymentprocessed());
         iscomplete = true;
   }

   public void consume(submitpaymentagain message)
   {
         var provider = paymentproviderfactory.create(message.paymenttype);
         if(provider.chargepayment(message...) == false)
         {
                if(state.failattempts == 3)
                {
                     bus.send(new paymentnoprocessed{...});
                     iscopmlete = true;
                     return;
                }

                state. failattempts ++;
                var paymenttype = provider.getnextpaymentmethod(message...);
                bus.delaysend(datetime.now.addhours(4), new 
submitpaymentagain{paymenttype});
         }
   }
}

On Friday, March 23, 2012 5:10:00 AM UTC-4, Erik Juhlin wrote:
>
> I'm new to service buses, but we have a problem that we think a 
> service bus might solve. 
>
> When communicating with an external service, we want to try X number 
> of times before putting it in an error queue or perhaps doing 
> something else (e.g. switch from credit card provider to invoice 
> provider). 
>
> But we don't want to do these calls directly after eachother. We want 
> to wait a certain time to give the external provider a chance to wake 
> up after a crash. 
>
> It seems like the Rhino Service Bus can do the first part, but is 
> there a way to wait between retries? Or is a service bus not suitable 
> for this?

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rhino-tools-dev/-/78mAGvgU6GoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhino-tools-dev?hl=en.

Reply via email to