162
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
exception.
Message
);
}
}
_logger.
LogDebug
($
"GracePeriod background task is stopping."
);
}
.../...
}
In this specific case for eShopOnContainers, it’s executing an application method that’s
querying a
database table looking for orders with a specific state and
when applying changes,
it is publishing
integration events through the event bus (underneath it can be using RabbitMQ or Azure Service Bus).
Of course, you could run any
other business background task, instead.
By default, the cancellation token is set with a 5 seconds timeout, although you can change that value
when building your
WebHost
using the
UseShutdownTimeout
extension of the
IWebHostBuilder
. This
means that our service is expected to cancel within 5 seconds otherwise it will be more abruptly killed.
The following code would be changing that time to 10 seconds.
WebHost.
CreateDefaultBuilder
(args)
.
UseShutdownTimeout
(TimeSpan.
FromSeconds
(
10
))
...
Dostları ilə paylaş: