The String codec connectivity plug-in
The String codec can be used for transports that are dealing with binary payloads which represent strings. It does bidirectional translations between string payloads and binary payloads:
The payload of a message going from the host to the transport should be of
java.lang.String (Java) or
const char* (C++) type. The String codec translates the payload of such a message to the
byte[] (Java) or
buffer_t (C++) type.
The payload of a message going from the transport to the host should be of
byte[] or
buffer_t type. The String codec translates the payload of such a message to the
java.lang.String or
const char* type.
The String codec always does UTF-8 encoding and decoding of a string:
When converting to a
buffer_t or
byte[], the end result is UTF-8 encoded.
When converting to a
java.lang.String or
const char*, the String codec assumes that the source (
buffer_t or
byte[]) is UTF-8 encoded.
To reference the String codec, an entry such as the following is required in the
connectivityPlugins section of the configuration file (see also
Configuration file for connectivity plug-ins):
stringCodec:
libraryName: connectivity-string-codec
class: StringCodec
You then need to add the String codec into your connectivity chain with the configuration for that instance. An example configuration may look as follows:
startChains:
testChain:
- apama.eventString
- stringCodec:
nullTerminated: false
- myBinaryTransport
The following configuration option is available for the String codec:
Configuration option | Description |
nullTerminated | If set to true, the binary payload transport-side includes the null-terminator in the string payload on the host-side. If set to false, the null-terminator is removed on transportward messages and added to hostward messages. Default: false. |