我試圖:從端點獲取消息。該消息將包含序列化的MessageClass。我只想在MessageClass.MessageIdentifier是唯一的時候開始一個新的傳奇。NServiceBus:文檔'<SagaName>'不再存在,可能已被刪除
我的傳奇是這樣的:
public class TrackingSaga:Saga<TrackingSagaData>,IAmStartedByMessages<InsertMessgae>,IHandleMessages<DeleteMessage>
{
private IBusinessService _trackingBusinessService;
public override void ConfigureHowToFindSaga()
{
ConfigureMapping<DeleteMessage>(s => s.ReferenceKey, p => p.ReferenceKey);
ConfigureMapping<InsertMessage>(s=>s.MessageIdentifier,p=>p.MessageIdentifier);
}
}
public void Handle(InsertMessage message)
{
Data=new TrackingSagaData(message.MessageClass)
{
MessageIdentifier = message.MessageClass.MessageIdentifier;
}
var trackingBusinessService = <<spring will provide me>> ;
trackingBusinessService.RecordNewMessage(message.MessageClass);
}
這裏是佐賀數據:
public class TrackingSagaData : ParentSagaData
{
public MessageClass MessageClass { private set; get; }
[Unique]
public Guid ReferenceKey { get { return MessageClass.ReferenceKey; } }
public string MessageIdentifier { get { return MessageClass.MessageIdentifier; } }
public bool IsMessageDeleted { set; get; }
public TrackingSagaData()
{
}
public TrackingSagaData(MessageClass messageClass)
{
MessageClass= messageClass;
IsMessageDeleted = false;
}
這裏是公交車的配置:
Configure.With()
.Log4Net()
.DefaultBuilder()
.XmlSerializer()
.RavenSubscriptionStorage()
.MsmqTransport()
.IsTransactional(true)
.PurgeOnStartup(false)
.RavenPersistence()
.UnicastBus();
當我跑我的終點時,控制檯顯示警告:
2014-06-27 18:17:10,040 [Worker.14] WARN NServiceBus.Unicast.UnicastBus [(null)
] <(null)> - IncidentTrackingSaga failed handling message.
System.InvalidOperationException: Document 'trackingsagadata/1fcfd00d-6b97-4
dc2-aa09-18a1bd0631e2' no longer exists and was probably deleted
2014-06-27 18:17:10,070 [Worker.14] WARN NServiceBus.Unicast.Transport.Transact
ional.TransactionalTransport [(null)] - Failed raising 'transport message receiv
ed' event for message with ID=88d86af8-5925-4975-ac72-7e68885070ab\18218
NServiceBus.Unicast.Transport.TransportMessageHandlingFailedException: Exception
of type 'NServiceBus.Unicast.Transport.TransportMessageHandlingFailedException'
was thrown.
但是,如果我去掉語句:
ConfigureMapping<InsertMessage>(s=>s.MessageIdentifier,p=>p.MessageIdentifier);
和
MessageIdentifier = message.MessageClass.MessageIdentifier;
那麼整個應用程序運行正常,但對於相同的消息是越來越創造了新的傳奇。我知道這是因爲RecordNewMessage()會在數據庫中寫入,並且我看到多個插入的MessageClass.MessageIdentifier。
你可以提供一些背景知道你想做什麼? –
每隔1分鐘(例如)一條消息將顯示在端點的隊列中。該消息將包含多個屬性,成員變量對於顯示的每條消息都會有所不同。只有MessageIdentifier可能會/可能不會相同。 我只想在MessageIdentifier不是新的時候開始新的傳奇。 希望這能更清楚地說明情況。 – user3344591