Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProcessManager - AppendEventsToStreamAsync - SQL call incorrect exception handler #235

Open
alexverdes30 opened this issue Aug 3, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@alexverdes30
Copy link

If SQL insert statement fails, the same exception code is raised - WrongExpectedVersion - and the initial error is not returned to the application.


declare @p5 Web.NewEventStoreEvents
insert into @p5 values('D318360C-CBF7-42DB-843E-730D2D85668A',N'{"ReceivedEvent":{"PartnerId":33608627,"Params":[{"Item1":"TriggeredByDocumentPartnerId","Item2":"54102"}]},"ReceivedEventType":"Charisma.Leasing.PublishedLanguage.Events.Partner.MasterPartnerConsentUpdated"}','NBB.ProcessManager.Runtime.Events.EventReceived, NBB.ProcessManager.Runtime','FBF236D4-1A6D-430C-915F-756F4D341B7C')

exec sp_executesql N'declare @NewEventsCount int
select @NewEventsCount = count(*) from @NewEvents
if @NewEventsCount = 0
begin
	return;
end

declare @ActualVersion int
select @ActualVersion = count(*) from EventStoreEvents where StreamId = @StreamId

if @ActualVersion <> @ExpectedVersion
BEGIN
	RAISERROR(''WrongExpectedVersion'', 16, 1);
	RETURN;
END



BEGIN TRY
	insert into EventStoreEvents(EventId, EventData, EventType, CorrelationId, StreamId, StreamVersion)
	select EventId, EventData, EventType, CorrelationId, @StreamId, @ExpectedVersion + OrderNo
	from @NewEvents
END TRY
BEGIN CATCH
	RAISERROR(''WrongExpectedVersion'', 16, 1);
END CATCH

',N'@StreamId varchar(200),@ExpectedVersion int,@NewEvents [NewEventStoreEvents] READONLY',@StreamId='Deimos.Worker.Processes.PartnerSyncProcess:NBB.Core.Effects.Unit:33608627',@ExpectedVersion=95,@NewEvents=@p5

Deimos

@alexverdes30 alexverdes30 added the bug Something isn't working label Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant