Asynchronous direct calls and map status queries

The following command runs a map asynchronously and requests all outputs, the audit log, and the trace log to be returned from the map. To run a map asynchronously, you must set rest.mode in the install_dir/config.yaml configuration file.

> curl -X POST -F "1=Card1 data" -F "2=Card2 data" http://localhost:8080/tx-rest/v1/itx/maps/direct/TwoInTwoOut?output=1,2&return=audit,trace
POST Runs the map asynchronously.
-F "1=Card1 data" -F "2=Card2 data" Overrides input card 1 and input card 2 with multi-part form data.
http://localhost:8080/tx-rest/v1/itx/maps/direct The hostname and port of the web server where the tx-rest.war file is deployed, and the base URL for invoking maps directly.
TwoInTwoOut The path to the compiled map file, relative to the rest.persistence.maps path specified in the in the install_dir/config.yaml file. The map file type (.mmc) is not required.
output=1,2 Overrides output cards 1 and 2 and returns a link to the data for both output cards in the response.
return=audit,trace Returns a link to the audit log and trace log in the response when the map completes.
preserveAudit=[true|false] and preserveTrace=[true|false] Setting these parameters to true ensures that physical log files are preserved for asynchronous map runs. If set to false, the log files are suppressed to save server space.

Running a map asynchronously immediately returns a response similar to the following. The response contains the URL that an application can use to query the status of a queued or long-running map.

{"id":"8b1f7e5e-5d16-480b-a972-03d66949cf7b", "href":"http://localhost:8080/tx-rest/v1/itx/maps/direct/8b1f7e5e-5d16-480b-a972-03d66949cf7b/status"}

Use a GET requests and the URL from the response to query the map status:

> curl -X GET http://localhost:8080/tx-rest/v1/itx/maps/direct/8b1f7e5e-5d16-480b-a972-03d66949cf7b/status
Note: If a POST request uses preserveAudit=true or preserveTrace=true, the log data is diverted to physical files on the server. Consequently, attempting to use the GET Map Audit or GET Map Trace APIs (for example, GET /v1/itx/maps/direct/{id}/audit or /v1/itx/maps/direct/{id}/trace) to retrieve these logs will result in an error.

The response from the GET request indicates whether the map execution is in progress or queued, the start time, and the number of milliseconds that the map has been queued or running. Call GET repeatedly until the map completes.

When the map completes, the status response is similar to the following example:

{
  "outputs": [
    {
      "href": "http://localhost:8080/tx-rest/v1/itx/maps/direct/8b1f7e5e-5d16-480b-a972-03d66949cf7b/outputs/1",
      "mime_type": "application/octet-stream",
      "card_number": 1
    },
    {
      "href": "http://localhost:8080/tx-rest/v1/itx/maps/direct/8b1f7e5e-5d16-480b-a972-03d66949cf7b/outputs/2",
      "mime_type": "application/octet-stream",
      "card_number": 2
    }
  ],
  "status": 0,
  "audit_href": "http://localhost:8080/tx-rest/v1/itx/maps/direct/8b1f7e5e-5d16-480b-a972-03d66949cf7b/audit",
  "trace_href": "http://localhost:8080/tx-rest/v1/itx/maps/direct/8b1f7e5e-5d16-480b-a972-03d66949cf7b/trace",
  "status_message": "Map completed successfully",
  "elapsed_time": 3,
  "start_timestamp": "2018-03-26T19:28:21.085+0000"
}

Use GET requests and the returned URLS to retrieve the output data, audit log, and trace log.