Concurrently process streams for partitionBy

I had a quick look through existing topics, and couldn’t find this specific question.

I have the following projection:

fromStreams(’$et-eventType1’, '$et-eventType2, ‘$et-eventType3’)
.partitionBy(function (e)
{
return “MyPartition-” + e.data.aggregateId.replace(/-/gi, “”);

})

.when() //my handlers

``

First up, my projection starts, is it true to say that events from $et-eventType1 are processed, followed by $et-eventType2, and then finally $et-eventType3 ?

Assuming that is true, is there way to do this concurrently?

I had a look at foreachStreams, but that would create a partition per stream (which is not what I want)

Any advice?

Steven

My understanding is that the projection logic is triggered whenever an unprocessed event appears on one of the streams, and therefore the events would be processed in order based on the event’s timestamp, and not based on the order of the streams you specified.

You can look at the $all stream to see what order the events were entered into the system. That should be the order the events will be passed through your projection.

I have not seen anyone mention concurrent execution of projections, so I doubt if that is something that is available. Unless you are going to be hitting I/O, which I don’t think you can, you likely don’t need to worry about it running concurrently. Not to mention that concurrent execution could cause issues with event ordering if you were going to emit something from the stream, and it would not be clear how state would carry over from handling one event to another.

Stephen,

Thanks for replying.

Funnily enough, I had been debugging a projection and noticed one of the streams “stopped”, then another stream started, so realised it was working on date based.

With that in mind, I appreciate why concurrent processing wouldn’t work here.

Thanks again.