Pre-Initialization Queues

Learn how to use queues and the Command pattern to delay operations until the asynchronous initialization process is complete.

We'll cover the following

Another recipe to make sure that the services of a component are invoked only after the component is initialized involves the use of queues and the Command pattern. The idea is to queue the method invocations (only those requiring the component to be initialized) received while the component isn’t yet initialized, and then execute them as soon as all the initialization steps have been completed.

Let’s see how this technique can be applied to our sample db component.

Get hands-on with 1400+ tech skills courses.