com.netbilling.direct
Class BatchAgent

java.lang.Object
  extended by com.netbilling.direct.BatchAgent

public class BatchAgent
extends java.lang.Object

This class contains a stand-alone java application, that can be run from the command line. There is no need to do any java programming in order to use the BatchAgent. Communication between your own application and the java BatchAgent consist of putting batch files ready for processing into a directory, and waiting for the BatchAgent to process them and write out the result files to the same directory. In order to avoid race conditions and accidental processing of batch files, a number of steps must be followed before processing starts. Those steps are described below in the runAgent method.

In order to start using the BatchAgent, do the following:

  1. Create a property file (a text file) "batchagent.props" containing the following:
     drop_dir = /some/directory/path        (required, change to indicate a directory on yoru system)
     account_id = 110006559149              (required, your account number)
     poll_interval = 5                      (optional, how often to scan for batch files in seconds)
     server = secure.netbilling.com         (optional, defaults to secure.netbilling.com)
     https = true                           (optional, set to false to turn encryption off)
     verbose = false                        (optional, set to true to turn on debug output)
     dynip_sec_code = <code>  (only for dynamic IP clients, see access security screen)
  2. Start the BatchAgent using the following command:
    java -classpath direct-java-3.x.x.jar com.netbilling.direct.BatchAgent batchagent.props

  3. The direct-java-3.x.x.jar file contains the BatchAgent and our other direct mode classes; you should have downloaded this file from us.

  4. Design your own software to follow the steps described in the runAgent documentation below to process batch files.


    Constructor Summary
    BatchAgent(java.lang.String account, int pollfreq, java.lang.String dropdir, java.lang.String server, boolean https, boolean verbosemode)
              Create a BatchAgent
     
    Method Summary
    static void main(java.lang.String[] argv)
              A config file is needed as argument, containing the following keys:
     void runAgent()
              Runs the agent indefinitely, sleeping poll_interval seconds between each round.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    BatchAgent

    public BatchAgent(java.lang.String account,
                      int pollfreq,
                      java.lang.String dropdir,
                      java.lang.String server,
                      boolean https,
                      boolean verbosemode)
    Create a BatchAgent

    Parameters:
    account - the account_id to use at the server
    pollfreq - interval in seconds between scans of the drop directory
    dropdir - pathname to the directory where batches will be put
    server - server host name, "secure.netbilling.com"
    https - set to false to force encryption off
    verbosemode - true for verbose mode where informational messages are printed
    Method Detail

    runAgent

    public void runAgent()
    Runs the agent indefinitely, sleeping poll_interval seconds between each round.

    Errors that happen (transient file errors and network errors) are ignored.

    This is the sequence of events which you have to follow to make the agent process a batch with the server. All filename references are relative to the basename of the original csv file to be uploaded - that is, if the filename is myfile.in.csv, the basename is myfile

    1. Put the batch file in CSV format into the drop directory with a filename ending with .in.csv

    2. Touch a file in the drop directory with the same filename but ending with .in.ready

      the agent recognizes this and uploads the csv file to the server, puts any immediate rejects into the file ending with .out.rej, removes the .in.ready file and touches the file .out.ready to signal that the .out.rej file is readable.

      NOTE! The server will not begin processing yet at this point.

    3. Wait for the .out.ready file to appear, and check the .out.rej file to determine if you still want to start the batch. If you want to abort, simply remove all the files (.in.csv, .out.ready and .out.rej).

    4. If you want to start processing the uploaded batch, remove the .out.ready file and touch the .in.ready file again. you must leave the .out.rej file.

      the agent recognizes this combination of files as the signal to start processing at the server. the .in.ready and .out.rej files are deleted by the agent at this point, and each time the agent polls the server, it writes a .out.stat file containing the status of the batch.

    5. Look for the .out.stat file where you can read the current status of the batch.

      when the agent finds that the server has finished processing the batch, the result is downloaded and put in the .out.csv file and the .out.ready file is created by the agent.

    6. Wait for the .out.ready file to appear, signalling that the .out.csv file is ready for reading the results of the batch processing.

      when done, remove the .out.stat file, the .out.csv file and the .out.ready file (in that order!)


    main

    public static void main(java.lang.String[] argv)
                     throws java.lang.Exception,
                            java.lang.NumberFormatException
    A config file is needed as argument, containing the following keys:

    • drop_dir - the pathname of the directory to scan for batches
    • account_id - account_id to use at the server
    • poll_interval - interval in seconds between scans

    Throws:
    java.lang.Exception
    java.lang.NumberFormatException

    Version 3.1.1

    This is propriatary and confidential unpublished information. Copyright(c) 1999-2019, All rights reserved.