Operator HttpPost

Primitive operator image not displayed. Problem loading file: ../../image/tk$com.teracloud.streams.websocket/op$com.teracloud.streams.websocket.op$HttpPost.svg

This operator posts/sends the incoming tuple's text or binary content to a HTTP or HTTPS persistent (Keep-Alive) or non-persistent endpoint specified in the operator parameter named url.

This operator can also be made to perform GET and PUT HTTP request activities.

Every incoming tuple must have an rstring strData attribute whose text content (Plain text or XML or JSON) or a blob blobData attribute whose binary content that needs to be sent as the HTTP(S) PUT or POST payload. One of the input tuple's attributes should be of type rstring carrying the text payload if any to be sent, another attribute should be of type blob carrying the binary payload if any to be sent and another attribute should be map<rstring, rstring> requestHeaders populated with any application-specific custom HTTP request headers to be sent to the remote web server. These three attributes are mandatory and must be present in the input tuple though not necessarily in any particular order.

In addition, it can optionally have the following two attributes: rstring httpMethod that can either have GET or PUT or POST as the HTTP request activity to be performed. rstring urlQueryString can have a well formed URL query string to be sent along with the GET HTTP request. e.g: company=IBM&product=Streams&specialty=Real-Time-Data-Analytics.

A schema for this input stream will look like this along with any other application-specific attributes:

rstring strData, blob blobData, map<rstring, rstring> requestHeaders, rstring httpMethod, rstring urlQueryString
Even though, a given incoming tuple must have both the rstring and blob typed data attributes, only one of them at a time can carry the data to be sent to the remote server during a given HTTP PUT or POST. If the httpMethod attribute is not present or if it has a value of an empty string, then a HTTP POST will be performed as long as strData or blobData attribute has content to be sent.
On its output port, this operator emits a tuple containing the HTTP POST status code, status message, response headers, text based response and binary based response received from the remote web server. This output tuple's schema should be

int32 statusCode, rstring statusMessage, map<rstring, rstring> responseHeaders, rstring strData, blob blobData
To post/send text data, users can set this operator's contentType parameter to: * text/plain
  • application/xml
  • application/json
  • application/x-www-form-urlencoded
To send binary data, it should be set to application/octet-stream which tells this operator to use a web standard based mechanism available for including multipart MIME content.

Summary

Ports
This operator has 1 or more input ports and 1 or more output ports.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 15 parameters.

Required: url

Optional: contentType, createPersistentHttpConnection, delayBetweenConsecutiveHttpPosts, httpStatusCodesThatRequireRetry, httpTimeout, logHttpPostActions, maxRetryAttempts, tlsAcceptAllCertificates, tlsKeyPassword, tlsKeyStoreFile, tlsKeyStorePassword, tlsTrustStoreFile, tlsTrustStorePassword, waitTimeBetweenRetry

Metrics
This operator reports 5 metrics.

Properties

Implementation
Java

Input Ports

Ports (0)

Every incoming tuple must have an rstring strData attribute whose text content (Plain text or XML or JSON) or a blob blobData attribute whose binary content that needs to be sent as the HTTP(S) PUT or POST payload. So, one of the input tuple's attributes should be of type rstring carrying the text payload if any to be sent, another attribute should be of type blob carrying the binary payload if any to be sent and another attribute should be map<rstring, rstring> requestHeaders populated with any application-specific custom HTTP request headers to be sent to the remote web server. These three are mandatory attributes that must be present in the input tuple not necessarily in any particular positional order. In addition, it can optionally have the following two attributes: rstring httpMethod that can either have GET or PUT or POST as the HTTP request activity to be performed. rstring urlQueryString can have a well formed URL query string to be sent along with the GET HTTP request. e-g: company=IBM&product=Streams&specialty=Real-Time-Data-Analytics. So, a schema for this input stream will look like this along with any other application-specific attributes: rstring strData, blob blobData, map<rstring, rstring> requestHeaders, rstring httpMethod, rstring urlQueryString. Even though, a given incoming tuple must have both the rstring and blob typed data attributes, only one of them at a time can carry the data to be sent to the remote server during a given HTTP PUT or POST. If the httpMethod attribute is not present or if it has a value of an empty string, then a HTTP POST will be performed as long as strData or blobData attribute has content to be sent.

Properties
Ports (1...)

Optional input ports

Properties

Output Ports

Assignments
Java operators do not support output assignments.
Ports (0)

Emits a tuple containing the HTTP POST status code, status message, response headers and text or binary response received from the remote web server. This tuple's schema should becint32 statusCode, rstring statusMessage, map<rstring, rstring> responseHeaders, rstring strData, blob blobData. Any other matching attributes from the incoming tuple will be forwarded via the output tuple.

Properties

Ports (1...)

Optional output ports

Properties

Parameters

This operator supports 15 parameters.

Required: url

Optional: contentType, createPersistentHttpConnection, delayBetweenConsecutiveHttpPosts, httpStatusCodesThatRequireRetry, httpTimeout, logHttpPostActions, maxRetryAttempts, tlsAcceptAllCertificates, tlsKeyPassword, tlsKeyStoreFile, tlsKeyStorePassword, tlsTrustStoreFile, tlsTrustStorePassword, waitTimeBetweenRetry

contentType

Specify the MIME content type that you want. Default is text/plain.

Properties
createPersistentHttpConnection

This parameter specifies if we have to a create a persistent (Keep-Alive) HTTP connection or not. (Default: false)

Properties
delayBetweenConsecutiveHttpPosts

Do you want to have a tiny delay in millseconds between consecutive HTTP Posts? (Default: 0 milliseconds i.e. no delay)

Properties
httpStatusCodesThatRequireRetry

This parameter specifies a comma separated string containing zero or more HTTP status codes that must trigger a retry attempt on a PUT, POST or GET operation for a given incoming tuple. e-g: '503, 408, 504' (Default: Empty string)

Properties
httpTimeout

This parameter can be used to configure the three commonly used HTTP timeout settings namely connect, connection request and socket timeout all with one value. (Default: 30 seconds)

Properties
logHttpPostActions

Do you want to log HTTP POST actions to the screen? (Default: false)

Properties
maxRetryAttempts

This parameter specifies maximum retry attempts before giving up on a PUT, POST or GET operation for a given incoming tuple. Use this feature sparingly so as not to cause back pressure when this operator is processing a high volume of incoming tuples. (Default: 0 i.e. no retry attempt)

Properties
tlsAcceptAllCertificates

This parameter can be used to configure whether all TLS certificates can be accepted with a possibility for an insecure connection. If this parameter is set, the other two parameters tlsTrustStoreFile and tlsKeyStoreFile are not allowed. (Default: false)

Properties
tlsKeyPassword

This parameter specifies the password for the keys stored in the store.

Properties
tlsKeyStoreFile

This parameter if present should point to a key store file in JKS format which will be used for client authentication. This store should have client's certificate to prove its identity. When this parameter is present, then the tlsKeyPassword parameter must be present and the tlsKeyStorePassword can be optional.

Properties
tlsKeyStorePassword

This parameter specifies the password for the key store.

Properties
tlsTrustStoreFile

This parameter if present should point to a trust store file in JKS format which will be used for authenticating the remote web server. This store should have server's public certificate to verify its identity. When this parameter is present, then the tlsTrustStorePassword can be optional.

Properties
tlsTrustStorePassword

This parameter specifies the password for the trust store.

Properties
url

Specify the URL to which HTTP POSTs will be sent.

Properties
waitTimeBetweenRetry

This parameter specifies wait time in milliseconds between retry attempts after an error on a PUT, POST or GET operation for a given incoming tuple. Use this feature sparingly so as not to cause back pressure when this operator is processing a high volume of incoming tuples. (Default: 2000 milliseconds)

Properties

Metrics

nDataBytesReceived - Counter

Total number of data bytes received from the remote remote web server.

nDataBytesSent - Counter

Total number of data bytes sent to the remote remote web server.

nDataItemsReceived - Counter

Number of data items received from the remote web server.

nDataItemsSent - Counter

Number of data items sent to the remote web server.

nHttpPostFailed - Counter

Number of failed HTTP POSTs to the remote web server.

Libraries

Operator class library
Library Path: ../../impl/lib/com.teracloud.streams.websocket.jar, ../../opt/downloaded/*