Starting and stopping the work agent
In your WorkAgent
implementation class, implement the plugin method start to start the work listener
and perform any necessary initialization that must happen each time you
start the work agent.
Implement the plugin method stop and perform any necessary logic to stop your work agent.
Compare and contrast the start and stop methods with the setup
and teardown methods.
If you use the InboundIntegrationStartablePlugin startable plugin variant in the inbound integration
plugin, be aware that the main WorkAgent interface defines start and
stop methods with no arguments. The startable plugin variant implements the interface
IStartablePlugin. This interface defines method signatures of the start and
stop methods that take arguments. These start and stop
methods must call the appropriate method of the utility class
gw.api.integration.inbound.CustomWorkAgent.
- In each start method, call
CustomWorkAgent.startCustomWorkAgent(integrationName). - In each stop method, call
CustomWorkAgent.stopCustomWorkAgent(integrationName).
For the argument to those gw.api.integration.inbound.CustomWorkAgent methods, pass the inbound
integration name in the name attribute on the <custom-integration> element
in your inbound-integration-config.xml file.
The following Java example demonstrates this pattern for the controller of a custom implementation of a startable plugin.
import gw.api.integration.inbound.CustomWorkAgent;
import gw.api.server.Availability;
import gw.api.server.AvailabilityLevel;
import gw.api.startable.IStartablePlugin;
import gw.api.startable.StartablePluginCallbackHandler;
import gw.api.startable.StartablePluginState;
@Availability(AvailabilityLevel.MULTIUSER)
public class CustomStartableInboundIntegrationController implements IStartablePlugin {
private String _name = "exampleCustomIntegration";
...
private void start( StartablePluginCallbackHandler pluginCallbackHandler, boolean serverStarting ) {
try {
CustomWorkAgent.startCustomWorkAgent( _name );
} catch ( GWLifecycleException e ) {
throw new RuntimeException( e );
}
}
private void stop( boolean serverShuttingDown ) {
try {
CustomWorkAgent.stopCustomWorkAgent( _name );
} catch ( GWLifecycleException e ) {
throw new RuntimeException( e );
}
}
}
