Thanks Greg, I really appreciate that.
I understand the difference between these kinds, but i’m still feeling a little confused -
let me elaborate on my case so it may be more clear to you which part i don’t really get.
Here’s how i setup things:
- HTTP API.
- Stream per AR (e.g Order-bbc507d0-ecaf-40cc-8239-ba478ec63242)
- Single stream for commands named Commands
-
ProcessorManager:
- subscribes to event types (using system event-type projection - e.g $et-OrderCreated)
- writes to *Commands *stream.
-
ApplicationService:
- subscribes to Commands stream using Persistent Subscription:
- PUT /subscriptions/Commands/ {startFrom: 0} (ensure creation of subscription each time service inits)
- GET /subscriptions/Commands/ (poll)
- when cmd arrives, build AR state by applying all events on it.
- in such case events are fetched from GET /streams/- from 0 to current using ‘previous’ links.
- writes result event(s) to AR’s stream
- ProjectionService:
- subscribes to event types (using system event-type projection - e.g $et-OrderCreated)
- writes to read-side db.
As you can see above,
ProcessManagers & ProjectionServices are polling multiple streams (one per event type, each on its separate thread).
While AppServices holds a single persistent subscription each (/subscrtiptions/Commands/).
Each of the above will ACK / NACK accordingly against its own subscription.
Besides the fact that the service reads all history from 0 everytime it starts (which obviously delays its work)- everything is working as expected, but I obviously still don’t understand it as i would want to.
Now, just to validate myself- is my approach right?
Is it ok to create a (persistent) sub for each of event-type-streams the way i did?
Is it correct to rebuild AR state from GET /streams/?
Is it correct to use subscriptions the way i did? after all, (currently) i don’t have competing consumers (there’s only one per service-type)
Which subscription am i using? catchup? persistent? again, not sure how both differ - for me it seems that i’m using both at once…
I know that i’m missing something- i just hope it’s something small.
thanks again.
Gal