1
我一直在使用MassTransit自動加密狀態機。我很喜歡與那個狀態/傳奇機器一起工作,特別是它如何配置和設置,以及我可以爲狀態機提供實現契約的事件作爲消息。在.net中持久存儲的佐賀實現。替代Masstransit Saga?
這是怎麼能是這樣的:
//define the statemachine with a State class (ServiceState)
public class ServiceStateMachine :
AutomatonymousStateMachine<ServiceState>{
//define available states
public State Available { get; set; }
public State WaitForItem { get; set; }
//define available events
public Event<RequestItem> RequestItem { get; set; }
//configure the state machine and configure the store to use the ServiceState class
public void ConfigureStateMachineCorrelations(StateMachineSagaRepositoryConfigurator<ServiceState> r)
//bind events to contracts and conditions
r.Correlate(RequestItem,
(state, message) =>
state.CorrelationId == message.CorrelationId)
}
public ServiceStateMachine(IStateMachineActivityFactory activityFactory
{
State(() => Available);
State(() => WaitForItem);
Event(() => RequestItem);
//bind states, events, activities, custom actions...
During(Available,
When(RequestItem)
.Then((state, message) =>
{
state.ServiceId = message.ServiceId; // just an example baby!
})
.TransitionTo(WaitForItem)
.Then(() => _activityFactory.GetActivity<RequestItemActivity, ServiceState>())
}
是什麼樣的替代佐賀實現那裏都差不多,但沒有連接到MQ架構?我想我真正想要的是至少有一個內存持久存儲的狀態機或佐賀實現。
您可以自行使用自動密碼,與MassTransit完全分離。實際上,NHibernate集成也是一個單獨的庫。 –
@ChrisPatterson你能用一個例子回答這個問題嗎?我有或多或少與OP相同的問題,但很難找到完整的持久性示例。謝謝! – Anttu