Support DESK

Follow

H5.6 - REST Service - Proxy Engine

Previous Article matchIT Hub Index Next Article 

C# & Java proxy engine

The C# BatchClient use matchIT.Hub.ProxyEngine and the Java BatchClient uses com.matchIT.Hub.ProxyEngine. ProxyEngine encapsulates the http communication with the Hub Service in a class that has the same interface as the Hub API with the following additions:

Configuration

  • public void setHost(string hostName)
    Call this to set the host and port of the matchIT Hub Service. The default is localhost:8080.
  • public void setLogging( string filename, string severity )
    Configures logging.
  • public void setUploadBlockRecordLimit( int recordLimit )
    Set the maximum number of records to send per block.
  • public void setDownloadBlockRecordLimit(int recordLimit)
    Set the maximum number of records to download per block.
  • public void setCompressionMinSize(int minSize)
    The the block size (in bytes) over which to use compression.

Engines collection

  • public int[] getEngines()
    Returns an array of existing engine instance numbers.
  • public void createEngine()
    Create a new engine instance.
  • public void createEngine(String name)
    Create a new named engine instance.
  • public int getEngineId()
    Return the id number of the engine instance currently in use (so you can reuse it later).
  • public String getEngineName()
    Return the name (if any) of the engine instance currently in use.
  • public void setEngineId(int engineId)
    Call this instead of createEngine() if you want to reuse an existing engine already instatiated in the service and you know the id.
  • public void setEngineByName(String name)
    Call this instead of createEngine() if you want to reuse an existing engine already instatiated in the service and you know the name.
  • public void deleteEngine(int engineId)
    Delete a specified engine instance.
  • public void deleteEngine()
    Deletes the engine instance currently in use. I.e. The one specified in a prior call to setEngineId() or one created by a prior call to createEngine().

Data

  • public List<String> lookup(String record)
    Lookup a record and return an array of results sorted by score.
  • public void addTransaction( int table, string data, int timeoutInMS )
    Applies an A(dd), U(pdate), or D(elete) transaction. See the matchIT Hub Service documentation for "POST tables/<0,1,2>/update" for details.
  • public void flush(int table)
    Because both addData() and addTransaction(), behind the scenes, batch the records into blocks, when you are finished making calls to either of these methods you need to call flush(). N.B. You must also call flush() between adding data and adding transactions.
  • public void setInputFile(int Table, string Delimiter, string Filename, string Encoding, bool NoMore, int timeoutInMS)
    Post a filename to the service to load data from.
  • public void setUpdateFile(int Table, string Delimiter, string Filename, string Encoding, bool NoMore, int timeoutInMS)
    Post a filename to the service to load transactions from.

Results

  • public void setOutputFile(string Filename, string Encoding, int timeoutInMS)
    Post a filename to the service to write results to.
  • public string openDownloadStream(int timeoutInMS)
    Whilst records are still being added you can call getNextResult() to fetch any matching pairs one by one. Once you are finished adding data (and after waiting for the service to start producing results) you can call openDownloadStream() and thereafter getNextResult() will stream the results rather than making multiple http POSTs. openDownloadStream() returns the first record from the stream. If you have set a download block record limit, getNextResult() will return null when the end of the current block is reached. At which point, if more results are still available, you should call openDownloadStream() again to fetch the next block.

You can reuse ProxyEngine class as-is in your own projects to avoid the the need to deal directly with the REST Service, or use it as sample code that demonstrates how to make http calls.

Previous Article matchIT Hub Index Next Article 
Was this article helpful?
0 out of 0 found this helpful

0 Comments

Please sign in to leave a comment.