Blog Logo
TAGS

Why you should batch message processing and how to do it with .NET AsyncEnumerable

AsyncEnumerable is a sneaky abstraction that allows simplified and performant usage for iterating on pull-based and push-based sources. Pull-based approach involves querying specific data sources like relational databases, while push-based approach involves receiving notifications from external sources such as messaging systems or event stores. AsyncEnumerable helps in both approaches by enabling familiar foreach statements and efficiently handling notifications. Whether youre using Postgres Logical Replication or EventStoreDB API, AsyncEnumerable can improve performance and reduce memory pressure by loading only necessary data. Overall, utilizing AsyncEnumerable for batch processing can streamline your message processing workflows and optimize resource usage.