Skip to content

LocalEventBus Performance #11581

Answered by realLiangshiwei
mehmetuken asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

You can consider publishing batch event data.

For example:

var products = ObjectMapper.Map<List<CreateUpdateProductDto>, List<Product>(inputs);
await Repository.InsertManyAsync(products, autoSave : true);

await _localEventBus.PublishAsync(new ProductsEventData(products ));


public class ProductsEventData
{
    public IReadOnlyList<Product> Products { get; }

    public ProductsEventData(List<Product> products)
    {
        Products = products;
    }
}

public class ProductEventHandler : ILocalEventHandler<ProductsEventData>, ITransientDependency
{
    private readonly IRepository<ProductHistory> _productHistoryRepository;

    public ProductEventHandler(IRepository<ProductHistory> p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mehmetuken
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants