Top
Interstage Big Data Complex Event Processing Server V1.0.0 User's Guide
Interstage

5.9.6 Event Sender Sample Program

The event sender sample program is an event sender application that sends event data for testing in CSV format to an HTTP adapter.

Execution format

The execution format of the program is as follows:

/opt/FJSVcep/sample/sample1/bin/sendevent.sh eventType dataFilePath [ sendDestinationURL ]
Arguments
eventType

Specify which event type is to be used to send the data.

Specify the development asset ID of the target event type.

dataFilePath

Specify the path of the CSV format file that contains the event data.

sendDestinationURL

Specify the endpoint address of the HTTP adapter.

If this is omitted, the default is "http://localhost/CepEngineFrontServerService/HttpReceiver".

Information

Endpoint address of the CEP engine

The send destination URL of the CEP engine is as follows:

http://CEPengineAddress/CEPengineNameFrontServerService/HttpReceiver

The send destination URL of the CEP engine (CepEngine) of the CEP Server ("cephost.example.com") is as follows:

http://cephost.example.com/CepEngineFrontServerService/HttpReceiver

Source code

Below is the source code of the event sender sample program.

/opt/FJSVcep/sample/sample1/src/sample/HttpClient.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package sample;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpClient {

static String DEFAULT_URL = "http://localhost/CepEngineFrontServerService/HttpReceiver";

public static void main(String[] args) {
if (args.length != 2 && args.length != 3) {
System.err.println("Requires two or three arguments: event-type, file name, [URL]");
System.exit(1);
}
String eventType = args[0];
String fileName = args[1];
String url = DEFAULT_URL;
if (args.length == 3) {
url = args[2];
}

try {
BufferedReader br0 =
new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));

String str;
while ((str = br0.readLine()) != null) {
URL TestURL = new URL(url);
HttpURLConnection con = (HttpURLConnection) TestURL.openConnection();

con.setRequestMethod
("POST");
con.setRequestProperty("TYPE", "CSV");
con.setRequestProperty("EVENT-TYPE-ID", eventType);
con.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
con.setDoOutput(true);

BufferedOutputStream bos = new BufferedOutputStream(con.getOutputStream());
bos.write(str.getBytes("utf-8"));
bos.flush();
bos.close();

BufferedReader br1 = new BufferedReader(new InputStreamReader(con.getInputStream()));

String line;
while ((line = br1.readLine()) != null) {
System.out.println(line);
}
br1.close();
con.disconnect();
}
br0.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}