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

EventGroupProcessor does only execute the first registered handler for each event type #402

Open
Darkskald opened this issue Oct 16, 2023 · 3 comments

Comments

@Darkskald
Copy link

When running the example basic/5-cqrs-protobuf, using the group handlers (watermill v1.3.5, watermill-amqp/v2 v2.1.0)

	err = eventProcessor.AddHandlersGroup(
		"events",
		OrderBeerOnRoomBooked{commandBus},
		NewBookingsFinancialReport(),

		cqrs.NewGroupEventHandler(func(ctx context.Context, event *BeerOrdered) error {
			logger.Info("Beer ordered", watermill.LogFields{
				"room_id": event.RoomId,
			})
			return nil
		}),
	)

only the first handler for the RoomBooked event (OrderBeerOnRoomBooked) is executed, the output of the other handler is never visible. Upon interchanging them:

		NewBookingsFinancialReport(),
		OrderBeerOnRoomBooked{commandBus},

only the message from NewBookingsFinancialReport is displayed. From this observation I deduce that in the current implementation of EventGroupProcessors executes only the first handler for a specific event type and ignores all others.

@Darkskald
Copy link
Author

I created a PR that should solve that issue, unfortunately I confused 403 and 402... sorry for that!

@MagdielCAS
Copy link

Any updates regarding this? 6 months later and it is still an issue, I spent some hours trying to figuring out why my code didn't work when it actually was the lib that returned after the first execution

@germainc
Copy link

Agree this would be a good change. The only workaround seems to be multiple handler groups but that can create a huge mess. If you have a domain with 10 events and need a second handler for 1 of them, you now have a group with 9 extra handlers returning nil just to ack messages. You can turn on AckOnUnknownEvent but that's a terrible idea since you have to turn it on for the entire processor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants