Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }