コード例 #1
0
 public static EventActivityBinder <JobSaga> SendJobSlotReleased(this EventActivityBinder <JobSaga> binder, Uri destinationAddress)
 {
     return(binder.SendAsync(destinationAddress, context => context.Init <JobSlotReleased>(new
     {
         JobId = context.Instance.CorrelationId,
         context.Instance.JobTypeId
     })));
 }
コード例 #2
0
 public static EventActivityBinder <JobAttemptSaga, JobStatusCheckRequested> SendCheckJobStatus(this EventActivityBinder <JobAttemptSaga,
                                                                                                                          JobStatusCheckRequested> binder, JobAttemptStateMachine machine)
 {
     return(binder.SendAsync(context => context.Instance.ServiceAddress, context => context.Init <GetJobAttemptStatus>(new
     {
         context.Instance.JobId,
         AttemptId = context.Instance.CorrelationId
     }), context => context.ResponseAddress = machine.JobAttemptSagaEndpointAddress));
 }
コード例 #3
0
 public static EventActivityBinder <JobSaga> SendJobSlotReleased(this EventActivityBinder <JobSaga> binder, JobStateMachine machine)
 {
     return(binder.SendAsync(context => machine.JobTypeSagaEndpointAddress,
                             context => context.Init <JobSlotReleased>(new
     {
         JobId = context.Instance.CorrelationId,
         context.Instance.JobTypeId
     })));
 }
コード例 #4
0
 public static EventActivityBinder <JobAttemptSaga, StartJobAttempt> SendStartJob(this EventActivityBinder <JobAttemptSaga, StartJobAttempt> binder)
 {
     return(binder.SendAsync(context => context.Instance.ServiceAddress, context => context.Init <StartJob>(new
     {
         context.Data.JobId,
         context.Data.AttemptId,
         context.Data.RetryAttempt,
         context.Data.Job
     })));
 }
コード例 #5
0
 public static EventActivityBinder <JobAttemptSaga, JobStatusCheckRequested> SendCheckJobStatus(this EventActivityBinder <JobAttemptSaga,
                                                                                                                          JobStatusCheckRequested> binder, JobAttemptStateMachine machine)
 {
     return(binder.SendAsync(context => context.Instance.InstanceAddress ?? context.Instance.ServiceAddress,
                             context => context.Init <GetJobAttemptStatus>(new
     {
         context.Instance.JobId,
         AttemptId = context.Instance.CorrelationId
     }), context => context.ResponseAddress = machine.JobAttemptSagaEndpointAddress)
            .Catch <Exception>(ex => ex.Then(context => LogContext.Error?.Log(context.Exception, "Failed sending GetJobAttemptStatus"))));
 }
コード例 #6
0
 public static EventActivityBinder <JobAttemptSaga, StartJobAttempt> SendStartJob(this EventActivityBinder <JobAttemptSaga, StartJobAttempt> binder,
                                                                                  JobAttemptStateMachine machine)
 {
     return(binder.SendAsync(context => context.Instance.ServiceAddress, context => context.Init <StartJob>(new
     {
         context.Data.JobId,
         context.Data.AttemptId,
         context.Data.RetryAttempt,
         context.Data.Job
     }), context => context.ResponseAddress = machine.JobAttemptSagaEndpointAddress));
 }
コード例 #7
0
 public static EventActivityBinder <JobAttemptSaga, Fault <StartJob> > SendJobAttemptFaulted(
     this EventActivityBinder <JobAttemptSaga, Fault <StartJob> > binder, JobAttemptStateMachine machine)
 {
     return(binder.SendAsync(context => machine.JobSagaEndpointAddress, context => context.Init <JobAttemptFaulted>(new
     {
         context.Instance.JobId,
         AttemptId = context.Instance.CorrelationId,
         context.Instance.RetryAttempt,
         context.Data.Timestamp,
         context.Data.Exceptions
     })));
 }
コード例 #8
0
 public static EventActivityBinder <JobSaga, T> RequestJobSlot <T>(this EventActivityBinder <JobSaga, T> binder,
                                                                   JobStateMachine machine)
     where T : class
 {
     return(binder.SendAsync(machine.JobTypeSagaEndpointAddress, context => context.Init <AllocateJobSlot>(new
     {
         JobId = context.Instance.CorrelationId,
         context.Instance.JobTypeId,
         context.Instance.JobTimeout
     }), context => context.ResponseAddress = machine.JobSagaEndpointAddress)
            .TransitionTo(machine.AllocatingJobSlot));
 }
コード例 #9
0
 public static EventActivityBinder <JobSaga, JobSlotAllocated> RequestStartJob(this EventActivityBinder <JobSaga, JobSlotAllocated> binder,
                                                                               JobStateMachine machine)
 {
     return(binder.SendAsync(machine.JobAttemptSagaEndpointAddress, context => context.Init <StartJobAttempt>(new
     {
         context.Data.JobId,
         context.Instance.AttemptId,
         context.Instance.ServiceAddress,
         context.Instance.RetryAttempt,
         context.Instance.Job
     }), context => context.ResponseAddress = machine.JobSagaEndpointAddress)
            .TransitionTo(machine.StartingJobAttempt));
 }
コード例 #10
0
 public static EventActivityBinder <JobSaga> SendJobSlotReleased(this EventActivityBinder <JobSaga> binder, JobStateMachine machine,
                                                                 JobSlotDisposition disposition)
 {
     return(binder.SendAsync(context => machine.JobTypeSagaEndpointAddress,
                             context => context.Init <JobSlotReleased>(new
     {
         JobId = context.Instance.CorrelationId,
         context.Instance.JobTypeId,
         Disposition = disposition == JobSlotDisposition.Faulted && context.Instance.Reason.Contains("(Suspect)")
                 ? JobSlotDisposition.Suspect
                 : disposition
     })));
 }
コード例 #11
0
 public static EventActivityBinder <JobAttemptSaga, T> SendJobAttemptFaulted <T>(this EventActivityBinder <JobAttemptSaga, T> binder,
                                                                                 JobAttemptStateMachine machine)
     where T : class
 {
     return(binder.SendAsync(context => machine.JobSagaEndpointAddress, context => context.Init <JobAttemptFaulted>(new
     {
         context.Instance.JobId,
         AttemptId = context.Instance.CorrelationId,
         context.Instance.RetryAttempt,
         InVar.Timestamp,
         RetryDelay = context.Instance.RetryAttempt < machine.SuspectJobRetryCount ? machine.SuspectJobRetryDelay : default(TimeSpan?),
         Exceptions = new FaultExceptionInfo(new TimeoutException("The job status check timed out."))
     })));
 }
コード例 #12
0
 public static EventActivityBinder <JobSaga, JobAttemptCompleted> NotifyJobCompleted(this EventActivityBinder <JobSaga, JobAttemptCompleted> binder)
 {
     return(binder.SendAsync(context => context.Instance.ServiceAddress,
                             context => context.Init <CompleteJob>(new
     {
         JobId = context.Instance.CorrelationId,
         context.Instance.Job,
         context.Data.Timestamp,
         Duration = context.Data.Timestamp - context.Instance.Started ?? TimeSpan.Zero
     })).PublishAsync(context => context.Init <JobCompleted>(new
     {
         JobId = context.Instance.CorrelationId,
         context.Instance.Job,
         context.Data.Timestamp,
         context.Data.Duration
     })));
 }
コード例 #13
0
 public static EventActivityBinder <JobSaga, Fault <StartJobAttempt> > NotifyJobFaulted(this EventActivityBinder <JobSaga, Fault <StartJobAttempt> > binder)
 {
     return(binder.SendAsync(context => context.Instance.ServiceAddress,
                             context => context.Init <FaultJob>(new
     {
         JobId = context.Instance.CorrelationId,
         context.Instance.Job,
         context.Instance.AttemptId,
         context.Instance.RetryAttempt,
         context.Data.Exceptions,
         Duration = context.Data.Timestamp - context.Instance.Started
     })).PublishAsync(context => context.Init <JobFaulted>(new
     {
         JobId = context.Instance.CorrelationId,
         context.Instance.Job,
         context.Data.Exceptions,
         context.Data.Timestamp,
         Duration = context.Data.Timestamp - context.Instance.Started
     })));
 }