Basic usage help

Hi

So… I have am trying to wrap my head around GES again!

I have a solution that has 2 consol apps in.

The first - mainly taken from the repository test project:

https://gist.github.com/wayne-o/e1d6daf85b9525364f5f

this creates an aggregate, raises some events and saves it. All good so far. I have some streams with names like:

testAggregate-623b55e410c74eb2b2874198c462c36c

The second is the subscriber:

https://gist.github.com/wayne-o/686aa4207c43abb692bf

I want this to listen for events coming out of the eventstore so that i can pretend to update a readmodel or two.

My understanding is that to do this I would subscribe to a stream.

Issue is SubscribeToAll yields an access denied error

SubscribeToStream wants the name of a stream…

which is troublesome as the stream names being created are agregateName-Id - so there appears to be a stream per aggregate instance? Can’t I just subscribe to all testAggregate or is there a way to subscibe to the events themselves?

Can anyone advice me on what my next steps should be?

I want to subscribe to all WoftamEvents so that I can update the WoftamReadModel or whatever I call it…

Hi Wayne,

You can use the credentials ‘admin’ and ‘changeit’ to subscribe to all (either in the defaults or on the subscription call)

James

By default $all (subscribe to all) is a system stream which requires system level privs. There are controllable defaults see Default ACLs here https://github.com/EventStore/EventStore/wiki/Access-Control-Lists. The default is that you should have admin access.

As such just provide credentials of your admin user (or change the default).

Cheers,

Greg

bah beat me

HAHA!!

You’re doing ok on the Turing test btw - almost had me convinced :wink:

OK - brilliant

I can see my events are coming into the subscriber.

I now have a RecordedEvent coming into my read model

How do I get the data out of this so that i can decide what to do?

Do I deserialize the byte[] .Data?

How did you serialize them? :slight_smile:

If using the repository example I believe it uses json

Ok - cool - so the byte[] in Data will be JSON?

I believe so without reviewing the exact code you are using. From an Event Store perspective its just a byte [] and that is decided by you (though we recommend json :))

OK - so that’s cool and the gang…

Now I want to dial into another type of event - the wikiWikiWahJustHappenedEvent - in one place and then wikiWikiWahDidntJustHappen in another place…

How do I go about doing that?

Should I deserialize the events in a single place and route by convention or is there a better way to do it?

w://

It depends - you could subscribe to $et-wikiWikiWahJustHappenedEvent etc and pass different handlers or you could dispatch yourself

Out of curiosity, by “wikiWikiWahDidntJustHappen”, do you mean “received 5 ‘minutepassed events’ without receiving a wikiWikiWahJustHappenedEvent”? Or something else…

It’s just another event. Absolutely no real world usage.

OK so I have the following:

connection.SubscribeToStream("$et-wikiWikiWahJustHappened", false,

(subscription, @event) => Console.WriteLine(“recieved!!” + @event.OriginalEvent.EventId),

(subscription, reason, arg3) => { }, new UserCredentials(“admin”, “changeit”));

but when I run the event producing console app nothing happens this side anymore?

what is the $et- part? are there any docs for this?

–run-projections=all from the command line

You have to run with --run-projections=all and enable the bytype projection in the admin ui

Thanks guys!

And thanks for being patient with me.

:slight_smile:

No worries. To help you along a bit, the internal projection that does the $et streams is the equivalent of:

fromAll().

when({

$any : function(s,e) { linkTo(e.eventType, e); }

})

This makes a stream per event type which is quite useful in many scenarios as subscribers are interested in event type regardless of stream the event came into.

Cheers,

Greg