Long running Transform stage script in Event Streams module

Hi everyone,

We are starting to play with Event Streams and wondered if there are any best practices or things to avoid when using the Transform stage in an Event Stream? For instance, is it bad practice to call a system.net.httpClient() inside a Transform stage?

Specifically we're looking to use a Tag Event source (boolean trigger tag) and then make an http GET during Transform to enrichen the data before sending to PostgreSQL.

The system.net.httpClient() GET can take up to 600ms usually. We will have about 700 trigger booleans in the Tag Event source. Each tag can fire about once per second but not all 700 will fire at the same time.

Eww! GET implies an HTTP API call per boolean. If you can cache the responses, that may be OK, but you should consider batching and making one API for many tags together.

Yes, it's an HTTP API call per boolean. The API only has data for the current process (about 2 seconds after the boolean transitions to true). So I don't think I can batch them up. We're currently doing this with a Gateway Event Script using async calls to the API but I wondered if Event Streams could also do this...and if there was a benefit to using Event Streams over Gateway Event Scripts in this scenario

Yuck. With those constraints, I think I'd use a large custom thread pool so you have have a bunch of API calls in parallel, while minimizing thread creation overhead.

Thanks @pturmel. I figured you'd have a better suggestion.