Previous Inter-App Comm / The Orderly Shutdown Pattern Next

VI. Multithreaded Inter-app Communication: The Orderly Shutdown Pattern

A. What is a Pattern?

"A recurring solution to a problem in a context."

B. Pattern Template

Context – Server application conducting integral units of work that must not be interrupted (akin to the database concept of Atomic operation).

Problem – How to shutdown the server app without interrupting app during a critical phase (within some unit of work that would be hard to recover from if disrupted).

Forces – Unix offers “signals,” Windows-NT offers “Services” – each a platform-dependent device to control server startup and shutdown.

Java “… run anywhere” begs for a platform-independent approach.

Java language has necessary features and constructs to support a solution.

Solution – Use Java networking and threading language features to implement a portable mechanism as a reusable design pattern.

-- Strategies – Different strategies relate to the level of encapsulation of functional pieces, and the amount of multithreading in the solution. (For example, while there must be a thread blocking on a SeverSocket.accept() call, there may or may not be additional worker threads that must be notified that it’s time to quit – SeverSocket.setSoTimeout() allows other strategies.)

-- Structure - Sequence diagrams

                

Consequences – More threading increases complexity, albeit along fairly standardized lines. Worker threads allow encapsulation and scalability of function without additional design burden or code complexity.

Sample Code – See running examples portmanager-basic and portmanager-full.


Previous Inter-App Comm / The Orderly Shutdown Pattern Next

Copyright © 2018
iWay Technology Company
Boulder, Colorado USA
jt@iwaytechnology.com
A limited right to copy this page for
individual (non-commercial)
educational use only
is hereby granted.