The TIBCO StreamBase® Bidirectional Socket Writer Adapter was created to allow for two-way socket communication using a pair of adapters, one for reading, and one for writing. The pair of adapters work together by sharing the connections that are made. As the name implies, the writer allows for tuples to be converted and written out to one or more sockets.
This adapter allows you to create your own data transformations, or use pre-built ones, before sending the data on the wire. There are currently four pre-built data transformations available: CSV, JSON, BLOB, and serialized tuple. The data transformers convert each incoming tuple into a byte array and send that data to one or more sockets.
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 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: This field that shows the formal name of the adapter and the fully-qualified name of the class that implements the adapter. If the selected adapter is custom-written, you can click the class name link to open the Java source for this adapter. (Adapters provided by TIBCO StreamBase do not offer source view.)
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 (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 fragment. 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 epadmin container resume command (or its sbadmin equivalent), 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 fragment as a whole is suspended and later resumed.
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.
|Share connections with a Socket Reader (check box)||Specifies whether this adapter is to share connections with another adapter, if shared socket connections can be used for both reading and writing.|
|Socket Reader to share connections with (string)||The name of the socket reader that this adapter is to share socket connections with.|
|Share data transformer (check box)||If enabled, the writer uses the same data transformer as the reader. This allows you to maintain state in the transformer between read and write operations.|
|Port (int)||The port to use. When in server mode, this is the port to listen on. When in client mode, this is the default port to use when making new connections.|
|Server Mode (check box)||This option determines whether this adapter runs as a client (check box cleared) or as a server (check box selected).|
|Enable Control Port (check box)||This option determines whether this control port is available. The control port allows for commands to be sent to the adapter to start or stop in server mode, or to connect or disconnect in client mode.|
|Enable Status (check box)||This option enables a status port with status information about the state of the adapter during run time. Some common status tuples include connection and disconnection information.|
|Socket Identifier Field Name (string)||This required field determines which field of the incoming data determines which connection the data will be sent to. The
field can be left blank, in which case all incoming tuples are sent to all connections. This field is removed from the outgoing
tuple before being processed to send. To find a connection in the incoming data, the expected format is
|Close Connection After Write (check box)||If enabled the server will close the client connection after it writes a response back to the client.|
|Log Level||Controls the level of verbosity the adapter uses to send notifications to the console. This setting can be higher than the containing application's log level. If set lower, the system log level is used. Available values, in increasing order of verbosity, are: OFF, ERROR, WARN, INFO, DEBUG, TRACE, and ALL.|
|Max Connection Count (int)||The maximum number of incoming connections that this adapter allows at any given time. If a client tries to connect when the maximum number of connections is already reached, the connection is rejected and a status tuple is emitted.|
|Connection Backlog (int)||The backlog parameter is the maximum number of pending connections on the socket. Its exact semantics are implementation specific. In particular, an implementation may impose a maximum length or may choose to ignore the parameter altogether. If the backlog parameter has the value 0, or a negative value, then an implementation specific default is used.|
|Start Server At Startup (check box)||Determines whether the adapter starts the server when the application starts. If disabled, the end-user must enable the control port and emit a command tuple to start and stop the server.|
|Default Host Name (string)||The default host name to connect to. This value is used when the Connect at startup value is selected or when a command tuple is received that has null for the host value.|
|Connect at startup (check box)||Determines whether the adapter connects to the default host and port when the adapter starts.|
|Reconnect Count (int)||Determines how many times this adapter will retry to connect to a host.|
|Timeout Period (int)||The number of seconds to wait to try to connect after failing to connect.|
|Byte Order (option)||The byte order to use when converting data.|
|Buffer Size (int)||
The size of the read or write buffer used to hold data in transition from the socket to the data transformer. If this value is too small the application will emit error messages because of a full buffer.
|Data Field Name||The name of the String or Blob field in the input schema which will contain the data.|
|Fixed Length||The integer fixed length number of bytes to write. If this value is 0 or negative it is ignored and the length of the actual data is sent at the front of the packet. If this input data is less than this value the pad value will be used to pad to the length, if the length if greater than only the bytes up to the fixed length will be sent.|
|Fixed Length Pad Byte||The byte value to use when the input data value is less than the fixed length.|
|Length Field Length||The length of the length field. 1, 2, 3, 4, or 8 bytes for the size written at the front of the data packet|
|Write Length Includes Length||If enabled the size value sent at the start of the packet will include the length field length.|
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.
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.
Use the control port to send action commands to the adapter. The adapter can be run either in server mode (where it listens for connections) or client mode (where it makes outbound connections), and each mode has its own set of commands. Tuples enqueued on this port cause the adapter to start or stop a server, or to connect or disconnect clients.
Command, string, the command to send to the adapter.
If the adapter is in server mode, the values are:
START -- This tells the adapter to start the server and listen on the specified or default host and port. Any new connection established has a
host:portkey value which outputs on each data tuple.
STOP -- This tells the adapter to stop the server and close all client connections.
DISCONNECT - This tells the adapter to disconnect a client from the server. The
socketidentifermust be included and match a current connection.
If the adapter is in client mode, the values are:
CONNECT -- This tells the adapter to make a new connection to the specified or default host and port. The associated values
host:port:socketidentiferare used to identify this connection for further actions; those values are output as the socket identifier on all emitted data tuples.
DISCONNECT - This tells the adapter to disconnect from the specified or default host and port. The
host:port:socketidentifercombination must match the values used to initially make the connection.
Host, string. The host to connect to. This value is only valid when sending commands to adapters in client mode. If the value is null, the default value of the adapter is used.
Port, int. The port to use when making connections. If the value is null the default value of the adapter is used. If the adapter is in server mode, the port value determines which port to listen on. If the adapter is in client mode, the port is used for outgoing connections.
SocketIdentifier (Optional), string. Only used when the adapter is in client mode. If specified, this value is added to the socket identifier value emitted on the status port as the object field with the format
The status port is used to send status information tuples downstream to inform the user of changes.
type, string. The type of status information emitted on this port. Status types are:
Connection -- Indicates this message is about a connection.
Server -- Indicates this message is about the listening server.
Connected -- This type of action occurs when a new connection is made either as a client or server. The socket identifier will be outputted as the object of this message. For a server the socket identifier will be host:port and for clients it will be 'host:port:(optional) inputted socket identifier'
Disconnected -- This type of action occurs when a connection disconnects either as a client or server.
Failed -- A failure occurred and the failure message will be included.
Limit -- Used when in server mode, this message will be emitted when the max number of connections to the server has been reached.
Stopped -- Used when in server mode, sent when the server has been stopped.
Started -- Used when in server mode, sent when the server has been started.
object, string. This value may be null. If it is not null, it contains a value relevant to the status message. On new connections, this value contains the socket identifier of the new connection.
message, string. This is a formatted human readable message that explains the status message.
inputTuple. Not used for this adapter.