Executor Binding
The Executor binding enables applications to offload work to separate threads for processor-intensive tasks or outbound gateway implementations.
Overview
The Executor Bus Binding is a special bus binding that allows applications to provide send work (via a message) to be processed on a separate thread. The executor binding can be used to:
Perform processor-intensive work in a thread other than an application's main dispatch thread
Implement outbound gateways where the executing thread 'pushes' the sent message to an external system
Work done by the processor of an executor bus is acknowledged and therefore Guaranteed across failures.
For configuration details, see Executor Binding Configuration.
The Executor Bus is still in incubation and is classified as an experimental feature. The APIs may change as new features are added to this binding.
Architecture
+------------------+
| Application |
| (Main Thread) |
+--------+---------+
| send()
v
+------------------+
| Executor Bus |
| (Detached |
| Send Queue) |
+--------+---------+
| process()
v
+------------------+
| Processor |
| (Worker |
| Thread) |
+--------+---------+
|
v
+------------------+
| External |
| System |
| (e.g., SMTP) |
+------------------+How It Works
To use an executor bus, the application must:
Implement an ExecutorBusProcessor that handles the processing
Expose it via an ExecutorBusProcessorFactory configured for the bus
Acknowledge completed work via the provided Acknowledger as work is completed
Send the processor work in the form of messages that the processor will complete
Implementing an Executor Bus Processor
An executor bus needs an ExecutorBusProcessor to perform processing, which is supplied to the bus when it is created by its executor bus processor factory.
The Process Method
The ExecutorBusProcessor interface defines a single method:
Lifecycle Integration
Processors that need to open connections to external systems may implement LifecycleAwareExecutorBusProcessor to hook into the bus lifecycle:
onExecutorBusOpen()- Called when the bus is openedonExecutorBusStart()- Called when the bus is startedonExecutorBusClose()- Called when the bus is closed
Accessing Configuration Properties
Processor-related configuration properties from the bus descriptor can be retrieved from the provider config portion of the binding's descriptor:
Acknowledger
Regardless of whether or not an executor bus channel is configured to be Guaranteed, the bus will pass a non-null Acknowledger to the application and the application must call its acknowledge() method when processing has been completed.
The acknowledger can be called by any thread asynchronously, but its acknowledge() method may only be called once as the Acknowledger implementation is pooled.
Sample Implementation
The following pseudo-code illustrates how an executor bus processor can be implemented:
Implementing a Processor Factory
The processor factory returns instances of a processor for use by the executor bus. The executor bus will create a processor when the bus is created. In an AEP Engine, this will be when an engine is activated.
Example: E-mail Alert Gateway
This example demonstrates creating a gateway that bridges alerts received from Solace out through an email gateway.
Application Code
Configuration
Because the e-mail gateway bus is acknowledging its work after sending each e-mail, this application will guarantee that e-mail alerts will be sent, and by virtue of clustering will be highly available.
See Also
Executor Binding Configuration - Configuration reference
Messaging Model - Overview of Talon messaging
Configuring Bus Connections - General bus configuration
ExecutorBusProcessor- Processor interfaceLifecycleAwareExecutorBusProcessor- Lifecycle interfaceAbstractExecutorBusProcessorFactory- Factory base class
Last updated

