Access Competing Consumer Group Name

A quick Competing Consumer question:

We have a single stream with 5 Groups.
What we need to do, is when an Event is received in EventAppeared(EventStorePersistentSubscriptionBase subscription, ResolvedEvent resolvedEvent), is know which Group that was for.

private async void EventAppeared(EventStorePersistentSubscriptionBase subscription, ResolvedEvent resolvedEvent)

{

  • //Send to endpoint - but we want to send based on the Group it belongs to!*

  • subscription.Acknowledge(resolvedEvent);*

}

The Group name forms part of the endpoint we need to send that Event to, so the Stream name is not enough information.

Is this possible, or has anyone any other ides how to get round this?

At the moment, the only other way I can think of getting round this is to have a service per Group (so all Events are sent to a single endpoint)

Thanks in advance.

Steven

This could be added to the subscription quite easily we have it in the
constructor would just have to add a getter for it
https://github.com/EventStore/EventStore/blob/release-v3.6.0/src/EventStore.ClientAPI/EventStorePersistentSubscription.cs

There is another way you could do this as well that would work right
now using a bit of functional "magic"

private async void EventAppeared(string group,
EventStorePersistentSubscriptionBase subscription, ResolvedEvent
resolvedEvent)
{
//Send to endpoint - but we want to send based on the Group it belongs to!

subscription.Acknowledge(resolvedEvent);
}

when you subscribe

(sub, ev) => EventAppeared("groupname", sub, ev)

you know the group when you are subscribing

Cheers,

Greg

Looking at the source code in EventStorePersistentSubscriptionBase.cs, we want public access to private readonly string _subscriptionId;

Would that be possible?

Functional magic is working.

Thanks very much for the quick response!