here is the actual saga minus ctor args and properties
public class UserInitiatedDataTransferConsumer
: ISaga<DataTransferState>
, InitiatedBy<UserInitiatedDataTransferCommand>
, Orchestrates<DataTransferCommand>
, Orchestrates<ForceCompletionOfUserInitiatedCommand>
{
public void Consume(UserInitiatedDataTransferCommand message)
{
State = ...
var forceCompletionAt = date.AddMinutes(30);
bus.Send(new DataTransferCommand {CorrelationId = Id});
bus.DelaySend(forceCompletionAt, new
ForceCompletionOfUserInitiatedCommand {CorrelationId = Id});
}
public void Consume(DataTransferCommand message)
{
//processor.Process() would then call either Continue or
Complete.
processor.Process(this);
}
public void Consume(ForceCompletionOfUserInitiatedCommand message)
{
Warn("Forced the completion of the transfer saga for {0} at
{1:F}", State.Username, SystemTime.Now());
IsCompleted = true;
}
public void Continue()
{
bus.Send(new DataTransferCommand { CorrelationId = Id });
}
public void Complete()
{
notification.Send(emailaddress, body);
IsCompleted = true;
}
}
I'm assuming sagas can be completed any number of ways and the saga should
be able to maintain it's lifespan internally. am I incorrect with this
assumption?
I just had another idea. Complete() would only send the email, not complete
the saga. ForceCompletionOfUserInitiatedCommand would be the only way to
complete the saga. Does that seem hackish?
My code is making the assumption that consuming "N" number of
DataTransferCommands will complete in under 30 minutes. I wonder if there is
a better (more explicit) way to model that so I'm not choosing between 1 of
2 methods to complete the saga.
--
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
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.