Striim 3.9.8 documentation

HTTP Writer

Sends a custom response to an HTTP Reader source when the source's Defer Response property is set to True. If HTTPWriter does not return a response before the Defer Response Timeout specified in HTTPReader, HTTPReader will respond with error 408 with the body, "Request timed out. Make sure that there is an HTTPWriter in the current application with property Mode set to RESPOND and HTTPWriter property RequestContextKey is mapped correctly, or set HTTPReader property DeferResponse to FALSE, or check Striim server log for details."

property

type

default value

notes

Mode

java.lang.String

RESPOND

Do not change default value.

Request Context Field

java.lang.String

 

The name of the input stream field that contains the UUID of the HTTP Reader source that will send the response. This UUID is the value of the RequestContextField metadata field of the HTTPReader's output stream (see HttpCacheResponseApp.tql for an example).

Response Code Field

java.lang.String

"200"

Status code for the custom response. Typically the default value of "200" will be appropriate unless your application has multiple instances of HTTP Writer that will handle events with various characteristics (see HttpCacheResponseApp.tql for an example).

Response Headers

java.lang.String

Optionally, specify one or more header fields to be added to the custom response using the format <header name>=<value>. Separate multiple headers with semicolons. The value can be a static string (for example, Server="Striim") or the value of a specified input stream field (for example, Table=@metadata(TableName); Operation=@metadata{OperationName)).

To see how this works, run striim/docs/HTTPWriter/HttpCacheResponseApp.tql, open a terminal or command prompt, and enter the following (if Striim is not running on your local system, change 127.0.0.1 to the IP address of the Striim server):

curl --location --request POST '127.0.0.1:8765' \
--header 'Content-Type: text/csv' \
--data-raw 'COMPANY 1'

That will return the cache entry for Company 1:

{
  "BUSINESS_NAME":"COMPANY 1",
  "MERCHANT_ID":"D6RJPwyuLXoLqQRQcOcouJ26KGxJSf6hgbu",
  "PRIMARY_ACCOUNT_NUMBER":"6705362103919221351",
  "POS_DATA_CODE":0,
  "DATETIME":"2607-11-27T09:22:53.210-08:00",
  "EXP_DATE":"0916",
  "CURRENCY_CODE":"USD",
  "AUTH_AMOUNT":2.2,
  "TERMINAL_ID":"5150279519809946",
  "ZIP":"41363",
  "CITY":"Quicksand"
 }

Then enter the following:

curl --location --request POST '127.0.0.1:8765' \
--header 'Content-Type: text/csv' \
--data-raw 'COMPANY 99'

Since there is no entry for Company 99 in the cache, that will return:

{
  "MESSAGE":"Requested entry was not found in cache."
}

See the comments in HttpCacheResponseApp.tql for more information.