This section explains the socket adapter communication method.
Information
Due to the following performance advantages, use of a socket adapter can achieve higher throughput than with SOAP and HTTP adapters:
The event sender application can send multiple event data while connected to the CEP Server (input adapter). Since this can eliminate overheads associated with establishing and ending TCP/IP connections, throughput improves.
Event sender applications can send event data continuously without waiting for reception messages from the CEP Server (input adapter). Since this eliminates the time lag associated with waiting for a response from the CEP Server, throughput improves.
(Only if the input adapter does not use logging)
The socket adapter end point is a combination of the CEP Server IP address and the socket adapter port (any TCP port).
If the socket adapter is used, the listening port for event data must be specified as the socket adapter port in the engine configuration file.
See
Refer to Section 9.1.1, "Engine Configuration File" in the User's Guide for information on how to specify the socket adapter port.
This section explains the messages sent to the socket adapter.
Send message format
Data field | Size | Specified value |
---|---|---|
Event header | 4 bytes | Specify the data size of the event data field (bytes). Or, specify 0 to post a send complete notification (indicating event sending is completed) to the socket adapter. Possible range is 0 to 33,000,000. |
Event data | Variable size | Store the event data (described below). Specify this field if the event header field is other than 0 (send complete notification). |
Event data field format
Data field | Size | Specified value | |
---|---|---|---|
Event data format | 3 bytes | Specify CSV or XML (string). The format can also be specified in lower-case (csv or xml). | |
Event type ID | Size | 4 bytes | Specify the string length of the event type ID (bytes). |
Data | Variable size | Specify the event type ID text data. | |
Character set | Size | 4 bytes | Specify the string length of the character set (bytes). If the event data encoding is UTF-8, specify 0. |
Data | Variable size | Specify the character set text data. If UTF-8, omit this field. | |
Event data content | Size | 4 bytes | Specify the size of the event data content (bytes). |
Data | Variable size | Specify the event data text data. |
Example
In the following case, the send message byte array is as follows:
Event data format: CSV format
Event type ID: EVENTTYPE_01
Character set: Shift JIS
The send complete notification byte array is as follows:
This section explains the messages posted from the socket adapter.
Response message format
Data field | Size | Specified value |
---|---|---|
Response code | 4 bytes | Stores a 4-digit string showing the input adapter processing results. |
<Separator> | 1 byte | Stores a colon (:) (0x3A) as the separator character between the previous and next fields. |
Send success count | Variable size (0 to 19 bytes) | Stores the processing success count for event data at the input adapter (upper limit: LONG_MAX). This field is posted as a decimal string. For example, if the count is 0, one byte indicating "0" (0x30) is stored. If the maximum count, 19 bytes indicating 263 - 1 is stored. |
<Separator> | 1 byte | Stores a colon (:) (0x3A) as the separator character between the previous and next fields. |
Error message | Variable size | Stores the error message string. |
<End> | 1 byte | Stores a line feed (LF) (0x0A) as the error message end character. |
Point
When an error occurs, a message is output to the syslog and the engine log. Refer to "3.4 Error Processing" for information on error processing.
Response codes and various messages, in accordance with the processing result, are as follows:
Processing result | Response code and message (*1) |
---|---|
Normal end | 0000 |
Sending message completed normally. | |
None | |
Format error The data size exceeds 33,000,000 bytes. | M001 |
Bad Message data size [dataSize]. | |
cep10308e: Message Data Size is over. EngineId=cepEngineName, Size=dataSize | |
Settings content discrepancy The event type ID is not known. | M002 |
Unknown event type id [eventType]. | |
cep10108e: Event type is not found. EngineId=cepEngineName ,eventType=eventTypeId | |
Format error A format other than CSV or XML is specified for the event data format. | M003 |
Unknown event format [eventFormat]. | |
cep10114e: Unknown Event format. EngineId=cepEngineName, format=eventFormat | |
Format error Send message format error | M004 |
Data format is Abnormal. | |
cep10303e: Event data cannot read. Event is aborted. EngineId=cepEngineName, ClientIP=eventSenderIpAddress | |
Format error The character set is not known. | M005 |
Charset is Abnormal [characterSetName]. | |
cep10304e: Charset Name is abnormal. EngineId=cepEngineName, CharsetName=characterSetName | |
Processing result error An error occurred when decoding event data. | M006 |
Decoding event data failed. | |
cep10309e: Decoding event data failed. EngineId=cepEngineName | |
Settings content discrepancy The event data type does not match the deployed event type definition. | M007 |
It differs from the registered format [eventFormat]. | |
cep10116e: It differs from the registered format. EngineId=cepEngineName, format=eventFormat | |
Format error The event data size exceeds 32,000,000 bytes. | M008 |
Bad Event data size [eventDataSize]. | |
cep10310e: Event Data Size is over. EngineId=cepEngineName, Size=eventDataSize | |
CEP server not running | S001 |
Server is not Running. | |
cep10300w: FrontServer is not running. Event is aborted. EngineId=cepEngineName | |
Busy status The CEP Server is temporarily or permanently overloaded. | S002 |
Server is busy now. | |
cep10301w: FrontServer is busy. Event is aborted. EngineId=cepEngineName or cep10302e: FrontServer is continuously busy. Event is aborted. EngineId=cepEngineName | |
Processing result error Log output processing failed. | S003 |
Logging failed. | |
cep10401e: The Log was not able to be output. EngineId=cepEngineName, EVENT=receivedEvent, ERRORINFO=internalInformation Note: Newlines in received events are converted to  before output. If an event exceeds the length that can be output to the syslog, only partial event information is output to the syslog. |
*1: The contents of each row are as follows:
Top row: Response code
Middle row: Error message (variable information shown in italic)
Bottom row: Message output to syslog and engine log (variable information shown in italic)
Example
If 10 event data are sent and then a send complete notification is sent, the received message byte array is as follows when message send ends normally:
This section explains the procedures when a socket adapter is used, from connection using socket communication (TCP/IP) to disconnection.
The event sender application communicates in accordance with the procedures (processing flow) shown below.
Processing procedure:
Connect to the CEP Server socket adapter. (Establish connection)
Send event data. (Send message)
Send next event data (if required). (Repeat step 2)
Send a notification. (Send complete notification)
Receive response message from the CEP Server. (Receive message)
Send next event data (if required). (Go back to step 2)
If all event data sends are completed, close the connection. (End connection)
See
Refer to "3.3.3.1 End Point" for information on the input adapter end point at the connection destination when establishing a connection.
Refer to "3.3.3.2 Send Message" for information on message sending and the send complete notification.
Refer to "3.3.3.3 Response Message" for information on message reception.
This section explains notes related to the use of the socket adapter.
Sending messages continuously
If an error is detected at the socket adapter, a response message is posted before a send complete notification is received and the connection is closed.
In this case, the event sender application cannot continue to send messages (an error occurs for data sending). Therefore, have the event sender application interrupt message sending, then receive a response message from the socket adapter.
Sending messages that do not match the size information
If event data is sent that is less than the data size set in the "size information", the CEP Server will wait to receive the correct amount of data, and does not post a response message until the appropriate amount of data is sent.
In the event sender application, ensure that the "size information" matches the event data size.
Number of simultaneous connections
There is no maximum number of simultaneous socket adapter connections. Connections can be made up to the maximum number of operating system file descriptors.
However, to ensure efficient resource usage, close connections when the event sender application is not continuing to send data.
Point
The CEP Server side does not close connections unless an error is detected at the socket adapter.
Using logging at the input adapter
The socket adapter outputs logs at the time of a send complete notification.
Therefore, have the event sender application initiate a send complete notification for each individual message and receive a response message, as shown below.
If a send complete notification is not sent nor a response message received for each message, the send success count for response messages might be inaccurate.
Performance considerations
When small packets are sent via TCP/IP communication consecutively, communication performance may deteriorate due to two operations: the Nagle algorithm, which collects send messages until it receives ACK from the receiver and then attempts to send them, and the TCP delayed ACK, which attempts to return multiple ACK at one time.
To prevent consecutive sending of small packets, use a buffered stream provided by the programming language (such as java.io.BufferedOutputStream in Java) in the event sender application.
Even if a buffered stream is used, communication performance may deteriorate for the same reason if a send complete notification is sent for each message and a response message is received. In such cases, consider setting the TCP_NODELAY option, which disables the Nagle algorithm, in the event sender application. In Java, you can set this using the setTcpNoDelay method of the java.net.Socket class.