Subscriptions

Hello,

on application startup i’m subscribing with the C# client to all events i’m interested in with $et- using SubscribeToStreamFrom(…).

But in the early stage of the application lifetime not all events are in the event store (like e.g. CustomerDisabled). And i get a CatchUpError with an access denied exception. Not very helpful because i want to subscribe and handle them as soon as such an event is fired.

How can i subscribe to such events?

A catch up subscription will deliver them as they happen perhaps you can share your code? What user is the subscription being connected as?

If it’s subscribing to $et-whatever you will need to authenticate as ACL for system streams is admin only by default iirc. admin/changeit are the defaults.

However it seems you’re likely on a wrong course with subscribing like that, if you can share your code we can probably help.

James

Hello,

the EventStore is just running local and used without credentials for now.

The sample code for the dispatcher is available here: https://gist.github.com/dnauck/7231622

Each event handler (read model projections, etc) registers all events that it is handling in the dispatcher and then it add a subscription to $et-.

The SubscribeToAllFrom(…) was not working, as it also required admin permissions. And i don’t want to subscribe to all events, just the ones i need.

Thanks for your help.

Daniel

You are passing in the connection to this code. If I understand you properly you are not setting credentials on it. To read system streams such as $et or $all you need to have admin privs (or change the default acls to allow it). Try setting user credentials of user:changeit on your connection and things should work. Alternatively instead of using $et streams you could write your own projection that writes to user space streams and set privs on them how you see fit via stream metadata

https://github.com/eventstore/eventstore/wiki/Stream-Metadata-Parameters

https://github.com/eventstore/eventstore/wiki/Access-Control-Lists

Should be useful.

Cheers,

Greg

Hi Greg,

thank you. It works now.

I’m using the sample projection from your blog:

fromAll().

``when({

``$any : ``function``(s,e) { linkTo(``"EventType-" + e.type, e); }

``});

But is this the way to go in general or do you suggest any other way to go when subscribing to events?

Thanks.

If you want it in user space that’s correct. If you are running the $et system projection though you probably prefer to just use it’s streams as otherwise you do all the same work twice :slight_smile: just adding the credentials (or creating a different user and giving them admin rights) will allow you to subscribe to the system streams.

Cheers.

Greg