Contents
The TIBCO StreamBase® Web Input Adapter allows the StreamBase application to receive JSON-formatted tuples via a HTTP POST
request. When this adapter is placed on the canvas, it takes the input port's schema and creates a REST endpoint based on
the fully qualified path of the adapter, unless specified by the context path property. For example, if the adapter's path
including the container name is default.module1.webinput
then a REST endpoint is created at http://localhost:10090/default/module1/webinput using the default 10090 port. A default
web page is created at the root that lists all available endpoints and their schemas.
The root endpoint also provides a test page for each endpoint; to view the default page visit http://localhost:10090 when your application is running.
This section describes the properties you can set for this adapter, using the various tabs of the Properties view in StreamBase Studio.
Name: Use this required field to specify or change the name of this instance of this component, which must be unique in the current EventFlow module. The name must contain only alphabetic characters, numbers, and underscores, and no hyphens or other special characters. The first character must be alphabetic or an underscore.
Adapter: A read-only field that shows the formal name of the adapter.
Class name: Shows the fully qualified class name that implements the functionality of this adapter. If you need to reference this class name elsewhere in your application, you can right-click this field and select Copy from the context menu to place the full class name in the system clipboard.
Start with application: If this field is set to Yes (default) or to a module parameter that evaluates to true
, this instance of this adapter starts as part of the JVM engine that runs this EventFlow module. If this field is set to
No or to a module parameter that evaluates to false
, the adapter instance is loaded with the engine, but does not start until you send an sbadmin resume command, or until you start the component with StreamBase Manager.
Enable Error Output Port: Select this check box to add an Error Port to this component. In the EventFlow canvas, the Error Port shows as a red output port, always the last port for the component. See Using Error Ports to learn about Error Ports.
Description: Optionally enter text to briefly describe the component's purpose and function. In the EventFlow canvas, you can see the description by pressing Ctrl while the component's tooltip is displayed.
Property | Type | Description |
---|---|---|
Context Path | string | The context path for this REST endpoint, if empty the fully qualified path of this operator is used. |
Linked Web Input Response | string | The linked web input response adapter to use to complete a REST response via event flow. If this value is not set, a default REST response is sent for each REST call. |
Output Request Metadata | check box | If enabled, a field is output with each tuple that contains the http request metadata. This metadata field will contain extra details about the request such as headers and method. The output field is named SB_RequestData. |
Timestamp Format | string | The timestamp format used to convert timestamp fields. |
The input port is used to determine the schema of the inbound REST request. Any tuples entering this port are sent directly out on the output port untouched.
The output port will emit tuples that either entered this adapter via the input port or were received by the REST endpoint automatically created for this adapter on startup. If the Linked Web Input Response adapter is set, then a SB_ResponseId field is set as a unique Id for each REST called received by this adapter.
This section describes how the REST endpoint protocol works.
The Web Input adapter allows POST, PUT, GET, and DELETE requests with a JSON formatted body. The body must match the schema
of the input port of the adapter. For example, if the input schema is (ID string, Field1 string, Field2 string)
then the resulting JSON request must be {"ID":null,"Field1":null,"Field2":null}
fields are optional depending on your application.
Note for GET requests, the path parameters are converted into tuple fields (for example, http://localhost:10090/test?ID=123&Field1=test would create a tuple with the ID and Field1 fields set).
List path parameters are also valid by specifying the path parameter more than once. For example, http://localhost:10090/test?MyList=test1&MyList=test2 would be converted to a (MyList list(string)) in StreamBase.
If the Linked Web Input Response is not set then the response from a REST POST request will be a simple JSON encode response, and is one of:
-
{"Status":"OK"}
-
{"Type":"[exception type here]", "Error":"Reading", "Message":"[error message here]"}
-
{"Type":"[exception type here]", "Error":"Parsing", "Message":"[error message here]"}
If the Linked Web Input Response is set, then the response is sent when the tuple produced by this adapter enters the corresponding Web Input Response adapter and the REST response will be based on that adapter's input schema.
The adapter works with default configuration. If you want to modify how the adapter works, you can use the adapter configuration
section that starts with the <adapter-configurations>
element and containing one <adapter-configuration name="webstreams">
element, which itself contains exactly one <section name="webstreams">
element.
Only exactly one of these configurations is allowed per application, which all adapters will use if found.
This example configuration shows a web server that contains all available values.
<adapter-configurations> <adapter-configuration name="webstreams"> <section name="webstreams"> <setting name="Enabled" val="true" /> <setting name="Port" val="10090" /> <setting name="IdleTimeoutMS" val="0" /> <setting name="OutputBufferSize" val="32768" /> <setting name="RequestHeaderSize" val="8192" /> <setting name="ResponseHeaderSize" val="8192" /> <setting name="SendServerVersion" val="true" /> <setting name="SendDateHeader" val="false" /> <setting name="SelectorThreads" val="-1" /> <setting name="AcceptorThreads" val="-1" /> <setting name="ReuseAddress" val="true" /> <setting name="LingerTime" val="-1" /> <setting name="GZipMimeTypes" val="text/html, text/plain,text/xml,application/xhtml+xml,text/css, application/javascript,text/javascript,image/svg+xml" /> <setting name="WebSocketAsyncWriteTimeoutMS" val="0" /> <setting name="WebSocketIdleTimeoutMS" val="0" /> <setting name="SecurePort" val="10443" /> <setting name="SSLKeyStorePath" val="keystore"/> <setting name="SSLKeyStorePassword" val="tester"/> <setting name="SSLKeyStoreManagerPassword" val="tester"/> <setting name="SSLTrustStorePath" val="keystore"/> <setting name="SSLTrustStorePassword" val="tester"/> </section> </adapter-configuration> </adapter-configurations>
Setting | Type | Description |
---|---|---|
Enabled | true/false | If true the web server and all ports are started. If false no web server is started and all operators become no-ops. |
Port | integer | The port the web server will listen on for connections. |
IdleTimeoutMS | integer | The amount of time in milliseconds to wait for connections to send data. |
OutputBufferSize | integer | Set the size of the buffer into which response content is aggregated before being sent to the client. |
RequestHeaderSize | integer | Set the maximum size of a request header. |
ResponseHeaderSize | integer | Set the maximum size of a response header. |
SendServerVersion | true/false | If true, send the Server header in responses. |
SendDateHeader | true/false | If true, include the date in HTTP headers. |
SelectorThreads | int | The number of selector threads, or less than or equal to 0 for a default value. Selectors notice and schedule established connection that can make IO progress. |
AcceptorThreads | int | The number of acceptor threads to use, or -1 for a default value. Acceptors accept new TCP/IP connections. If 0, then the selector threads are used to accept connections. |
ReuseAddress | true/false | Whether the server socket reuses addresses. |
LingerTime | integer | The linger time. Use -1 to disable. |
GZipMimeTypes | string | Set the mime types associated with GZip requests. Blank or missing means do not use GZip. |
WebSocketAsyncWriteTimeoutMS | integer | The time in milliseconds before a write command times out. |
WebSocketIdleTimeoutMS | integer | The time in milliseconds before a web socket times out from idle behavior. |
SecurePort | integer | Set the TCP/IP port used for CONFIDENTIAL and INTEGRAL redirections. |
* SSLKeyStorePath | string | The file or URL of the SSL Key store. |
* SSLKeyStorePassword | string | The password for the key store. |
* SSLKeyStoreManagerPassword | string | The password (if any) for the specific key within the key store. |
* SSLTrustStorePath | string | The file name or URL of the trust store location. |
* SSLTrustStorePassword | string | The password for the trust store. |
* NOTE: Please refer to http://wiki.eclipse.org/Jetty/Howto/Configure_SSL when setting up SSL.