TDIing out loud, ok SDIing as well

Ramblings on the paradigm-shift that is TDI.

Tuesday, April 26, 2011

skipEntry() I thought I knew you...

When you want to abruptly end the current cycle of an AssemblyLine, a script call to
system.skipEntry()
is the most commonly used method. However, this is not always the best choice. In fact, it is only relevant when you have an Iterator in the Feed section. If you don't then
system.exitFlow()
is the better choice.

Except
if your AL has a Server mode Connector. To explain why, I'll have to say a bit first about how Server mode Connectors work.

A Server mode Connector (or SMC for short) adds two important features to your AL:
  • redundancy
  • AL pooling
Redundancy comes from the fact that when the AL starts, the SMC starts a thread that binds to the specified resource, for example an IP port. Whenever a client connects, a new thread is spawned to service this client. This thread is an AssemblyLine consisting of a copy of the SMC in Iterator mode, paired up with a Flow section from the AL pool. When this child AL terminates - for example, when the connection is closed or an error occurs in AL processing - the Flow section components are returned to the pool, ready for new connections.

As long as nothing breaks the SMC itself, e.g. if the bound resource fails, then new client connections will be handled by (re)launching ALs as needed.

The AL pool is not to be confused with Connector Pooling, which do you from your Connectors library (Resources > Connectors). Instead, under AssemblyLine Options you can define both the initial size and max size of this AL's pool. These settings only apply when a Server mode Connector is present in the AL Feed section. And note that Connectors (and connections to target systems) will be initialized for each copy in the pool. Pool initialization occurs when the SMC starts so that all connections are hot-and-ready to service client requests.

As a result of all this, when you want to stop Flow section execution you need to use
task.shutdown()
so that Connectors are released to the pool. Note that this will not result in the Server Connector making a reply back to the client. To do this you still need to use:
system.exitFlow()