Example of an inbound file integration

The following example configures inbound file integration in the inbound-integration-config.xml file.

<file-integration name="simpleFileIntegration" disabled="false">
  <threadpool>gw_default</threadpool>
  <pollinginterval>15</pollinginterval>
  <throttleinterval>5</throttleinterval>
  <ordered>true</ordered>
  <stoponerror>false</stoponerror>
  <transactional>false</transactional>
  <osgiservice>true</osgiservice>
  <traceabilityidcreationpoint>INBOUND_INTEGRATION_FILE</traceabilityidcreationpoint>
  <pluginhandler>SimpleInboundFileIntegrationHandler</pluginhandler>
  <processingmode>line</processingmode>
  <incoming>/tmp/file/incoming</incoming>
  <processing>/tmp/file/processing</processing>
  <error>/tmp/file/error</error>
  <done>/tmp/file/done</done>
  <charset>UTF-8</charset>
  <createdirectories>true</createdirectories>
</file-integration>

The following Gosu example implements a SimpleFileIntegrationHandler handler class to print the lines in the file.

package mycompany.integration

uses gw.plugin.integration.inbound.InboundIntegrationHandlerPlugin

class SimpleFileIntegrationHandler implements InboundIntegrationHandlerPlugin {
  // This example assumes that the inbound-integration-config.xml file
  // sets this integration to use "line" not "entire file" processing
  // See the <processingmode> element
  construct(){
    print("***************** SimpleFileIntegration startup")
  }

  override function process(obj: Object) {
    // Downcast as needed (to String or java.nio.file.Path, depending on value of <processingmode>
    var line = obj as String
    print("***************** SimpleFileIntegration processing one line of file: ${line} (!)")
  }
}

The example has two plugin implementations registered in the Plugins registry.

SimpleInboundFileIntegrationStartable.gwp
Registers an implementation of InboundIntegrationStartablePlugin with the Java class com.guidewire.pl.integration.inbound.file.DefaultFileInboundIntegrationPlugin. The integrationservice plugin parameter is set to simpleFileIntegration.
SimpleInboundFileIntegrationHandler.gwp
Registers an implementation of InboundIntegrationHandlerPlugin with the Gosu class mycompany.integration.SimpleFileIntegrationHandler.

When you start up the server, the log line from starting up the file inbound integration handler appears in the console.

***************** SimpleFileIntegration startup

The console also displays information about the directories that the inbound file integration uses for incoming, processing, and completed files. These directories are specified by the <incoming>, <processing>, and <done> elements in the <file-integration> definition. For the integration definition in this topic, the lines look like the following ones.

incoming [C:\tmp\file\incoming] 
processing [C:\tmp\file\processing] 
done [C:\tmp\file\done]

When you add files to the /tmp/file/incoming directory, you will see additional lines for each processed line. For example, add a file with the following content to the incoming directory:

Line 1
Line 2
Last line

The console contains lines that look like the following ones.

***************** SimpleFileIntegration processing one line of file: Line 1 (!)
***************** SimpleFileIntegration processing one line of file: Line 2 (!)
***************** SimpleFileIntegration processing one line of file: Last line (!)

See also