c# - NServiceBus Saga handle a message-type multiple times gives concurrency exception -
c# - NServiceBus Saga handle a message-type multiple times gives concurrency exception -
we have nservicebus implementation handles multiple message-types:
public class statecoordinator : saga<messagedata>, iamstartedbymessages<createmessage>, iamstartedbymessages<confirmmessage>
messagedata this:
public class flowdata : icontainsagadata { [unique] public guid mappingid { get; set; } public guid id { get; set; } public string originalmessageid { get; set; } public string originator { get; set; } public list<messagepart> messageparts { get; set; } } public messagepart { public int id { get; set; } public string status { get; set; } }
the createmessage has messagepart added messageparts in handler. confirmmessage updates status of particular messagepart.
this scenario:
1) first createmessage received. creates saga in raven , adds messagepart (with status "1") messageparts.
2) first confirmmessage received. updates status of first added messagepart in saga "1 2". vissible in browser when going document in ravendb.
3) sec createmessage received. adds sec messagepart messageparts. when looking data, status of first messagepart still "1" , not "1 2" , throws concurrency-exception (the actualetag not equals expectedetag):
a first chance exception of type 'raven.abstractions.exceptions.concurrencyexception' occurred in raven.client.lightweight additional information: set attempted on document 'flow/79a7ee20-f090-4648-9b62-a3da00d87c93' using non current etag
it looks saga-data cached per message-type. so? there solution?
note:
we using multiple iamstartedbymessages when confirmmessage before createmessage, message added queue until createmessage handled.
after few tests can there not real problem. think can't solve concurrency-exceptions (this exception logged) when exception occurs, message send queue retry.
i afraid logic handle executed twice guess because i've transactions enabled, not case. example: 1 of actions send message bus persist event (perister-queue). action called before exceptions occurs (after handle, info saved in saga , exceptions thrown) there no message added persister-queue. after retry of message succeeds (this updates info there isn't concurrency-exception anymore), persister-message added persister-queue.
conclusion: not real problem, line in log-file.
c# nservicebus bus saga nservicebus-sagas
Comments
Post a Comment