Web Server Request Adapter

Introduction

The TIBCO StreamBase® Web Server Request adapter allows StreamBase applications to handle HTTP and web socket requests. It is powered by an embedded Jetty web server. The web server request input adapter handles the parsing of HTTP data into an outgoing tuple which your code can handle and then feed the response into an associated Web Server Response output adapter. The adapter uses property values in the sbd.sbconf configuration file to set up the Jetty engine. For details, see the Configuration section below. Multiple web server request adapters can share a single instance of the Jetty web server engine by selecting the same web server configuration setting. A new Jetty web server instance is created for each port that is set in the configuration file.

Adapter Properties

This section describes the properties you can set for this adapter, using the various tabs of the Properties view in StreamBase Studio.

General Tab

Name: Use this field to specify or change the component's name, which must be unique in the application. 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: A field that shows the fully qualified class name that implements the functionality of this adapter. Use this class name when loading the adapter in StreamSQL programs with the APPLY JAVA statement. 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 or to a module parameter that evaluates to true, an instance of this adapter starts as part of the containing StreamBase Server. If this field is set to No or to a module parameter that evaluates to false, the adapter is loaded with the server, but does not start until you send an sbadmin resume command, or until you start the component with StreamBase Manager. With this option set to No or false, the adapter does not start even if the application as a whole is suspended and later resumed. The recommended setting is selected by default.

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 and Error Streams 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.

Adapter Properties Tab

Property Type Description
Web Server Config drop-down list This required field will select a value from the sbconf file which contains the configuration for the web server that this adapter will be associated to. This value is selected from the adapter-configuration section with name equal to webservers, section name equal to webserver, the value is pulled from the id parameter.
Request Id Field Name string The name used for the field in the outgoing data tuple that contains the request id for each HTTP request. The request id is used to associate this request connection with an outgoing response to send a response back.
Context Path string The path that this adapter will handle for the web server. The path should be anything after the root web address, for example http://localhost/test would have a target /test. A path can also be / which means handle all requests not handled by another adapter.
Enable Control Port checkbox When enabled, the adapter will allow incoming tuples to control the actions of this adapter.
Command Field Name string The name of the field in the incoming control tuple that contains the command.
Enable Status Port checkbox When enabled, the adapter will send out informational data on the status port about various states of the adapter.
Log Level Drop-down list Controls the level of verbosity the adapter uses to issue informational traces to the console. This setting is independent of the containing application's overall log level. Available values, in increasing order of verbosity, are: OFF, ERROR, WARN, INFO, DEBUG, TRACE, and ALL.

Request Tab

Property Type Description
Web Socket checkbox Determines if this context path should be treated as a web socket connection.
Web Socket Read Data Type radio Determines the type of data the will be read from the web socket connection.
Multipart/Form-Data checkbox Determines if this endpoint should process multipart/form-data (file uploads). This is normally via a POST request with form values. If POST data contains inputs with of type file, then the files will be saved to the file system and the full path to the file is given in the output tuple files list. If there are other input fields, they are added to the parameters list of the outgoing data tuple.
File Storage Path string The path (relative or full) to the location of where to store files sent via HTTP multipart/form-data POST requests.
Request Data Outgoing FieldName string The name given to the field in the outgoing data tuple which will contain the web request data. This value is optional, and if left blank request data will not be included in the outgoing data tuple.
Request Data Parameter Name string The name given to the field in the outgoing data tuple which will contain the web request parameter data. This value is optional, and if left blank request parameter data will not be included in the outgoing data tuple.
Request Callback Parameter Name string The name given to the field in the outgoing data tuple which will contain the web request callback name, commonly used for JSONP requests. This value is optional, and if left blank request callback name will not be included in the outgoing data .

Parameters Schema Tab

Property Type Description
Parameters Schema schema The schema used to map the incoming parameters of a request to a well defined schema. NOTE: Name mapping to parameters is case sensitive.

Concurrency Tab

Use the Concurrency tab to specify parallel regions for this instance of this component, or multiplicity options, or both. The Concurrency tab settings are described in Concurrency Options, and dispatch styles are described in Dispatch Styles.

Caution

Concurrency settings are not suitable for every application, and using these settings requires a thorough analysis of your application. For details, see Execution Order and Concurrency, which includes important guidelines for using the concurrency options.

Control Port

Description

Use the control port is used to send action commands to the adapter. Tuples enqueued on this port cause the adapter to start or stop a server.

Control Port Schema

  • Command, string, the command to send to the adapter.

    The values are:

    • START -— Tells the adapter to start the server and listen on the port specified in the configuration.

    • STOP -— Tells the adapter to stop the server and close all client connections.

Status Port

Description

The status port is used to send status information tuples downstream to inform the user of changes.

Status Port Schema

  • type, string. The type of status information emitted on this port. Status types are:

    • WebServer — Indicates this message is about a web server.

    • WebSocket — Indicates this message is about a web socket connection.

  • action, string.

    • Error — A error has occurred

    • Command — A command status information is being reported such as start and stop of server.

    • Closed — A web socket has been closed.

    • Connected — A web socket has connected.

  • object, string. This value may be null. If it is not null, it contains a value relevant to the status message.

  • message, string. This is a formatted human readable message that explains the status message.

Configuration

Description

The web server adapter configuration section starts with an <adapter-configurations> element containing one <adapter-configuration name="webservers"> element that contains one or more <section name="webserver"> elements.

Each <section name="webserver"> configuration must contain a <setting name="id" val="Web Server Port nnnn"/> and <setting name="Port" val="nnnn" /> settings fields. All other setting elements are optional.

This example configuration shows two different web servers, the first contains all values available and the second shows the required values. You can have as many configurations as your application requires, but each must have a unique port number and a unique id.

Example

           <adapter-configurations>
               <adapter-configuration name="webservers">
                   <section name="webserver">
                       <setting name="id" val="Web Server Port 8080"/>
                       <setting name="Port" val="8080" />                
                       <setting name="StartOnStartup" val="true" />
                       <setting name="IdleTimeoutMS" val="30000" />                
                       <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="5000" />
                       <setting name="WebSocketIdleTimeoutMS" val="30000" />                
                       <setting name="SecurePort" val="8443" />
                       <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>
                   <section name="webserver">
                       <setting name="id" val="Web Server Port 9090"/>
                       <setting name="Port" val="9090" />
                   </section>
               </adapter-configuration>        
           </adapter-configurations>
         

Settings

Setting Type Description
id string The value to display in the drop down list and is used to key to this section of the configuration file.
Port integer The port the web server will listen on for connections.
StartOnStartup true/false Start the web server on adapter startup.
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 behaviour.
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