public async Task Handle(ProductCreated notification, CancellationToken cancellationToken) { // invalidate cache await _cacheService.RemoveAllKeysAsync($"{CacheKeys.ProductsKey}:*"); // do publish this changes to external services await _daprClient.PublishEventAsync("pubsub", "product-created", notification, cancellationToken); }
public async Task Handle(ProductCreated notification, CancellationToken cancellationToken) { // invalidate cache await _cacheService.RemoveAllKeysAsync($"{CacheKeys.ProductsKey}:*"); // do publish this changes to external services if (!notification.MetaData.TryGetValue("id", out var id)) { throw new Exception("Couldn't get id from metadata"); } notification.Id = (int)id; await _daprClient.PublishEventAsync("pubsub", "product-created", notification, cancellationToken); }