C# & Java proxy engine
The C# BatchClient uses matchIT.Hub.ProxyEngine and the Java BatchClient uses com.matchIT.Hub.ProxyEngine. ProxyEngine encapsulates the http communication with the Syniti Match API Service in a class that has the same interface as the Syniti Match API.
You can reuse ProxyEngine class as-is in your own projects to avoid the need to deal directly with the REST Service, or use it as sample code that demonstrates how to make http calls.
The C# ProxyEngine implements the interface matchIT.Hub.IHub defined in HubInterface.dll. The Java ProxyEngine implements the interface com.matchIT.Hub.Hub defined in hubInterface.jar. These are the same interfaces implemented by the corresponding Syniti Match API Engine classes - so if you code to the interface in your application you can switch between calling Syniti Match API directly and calling it via the REST Service without having to recode.
Beside implementing the Syniti Match API Interface, ProxyEngine has the following additional functionality:
Configuration
- public void setHost(string hostName)
Call this to set the host and port of the Syniti Match API 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 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 Syniti Match API 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.