I'm implementing a cell that publishes a RTW (Push) and waits for Activities. However, under certain circumstances I want to take back the RTW and replace it with a RTW (Pull). Following is a simplified example of what I want to achieve:
public class SomeCell: Cell
{
[EntrySerialize]
public void SendReadyToWorkPush()
{
var rtw = Session.StartSession(ActivityClassification.Production, ReadyToWorkType.Push);
PublishReadyToWork(rtw);
}
[EntrySerialize]
public void SendReadyToWorkPull(long processId)
{
// Take Back any previous RTW Push that was send
var rtw = Session.StartSession(ActivityClassification.Production, ReadyToWorkType.Pull, processId);
PublishReadyToWork(rtw);
}
}
You should remember the last published session and publish a NotReadyToWork.
public class SomeCell : Cell
{
private ReadyToWork _rtw;
[EntrySerialize]
public void SendReadyToWorkPush()
{
var notReadyToWork = _rtw.PauseSession();
PublishNotReadyToWork(notReadyToWork);
_rtw = Session.StartSession(ActivityClassification.Production, ReadyToWorkType.Push);
PublishReadyToWork(_rtw);
}
[EntrySerialize]
public void SendReadyToWorkPull(long processId)
{
// Take Back any previous RTW Push that was send
var notReadyToWork = _rtw.PauseSession();
PublishNotReadyToWork(notReadyToWork);
_rtw = Session.StartSession(ActivityClassification.Production, ReadyToWorkType.Pull, processId);
PublishReadyToWork(_rtw);
}
}