-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.java
More file actions
43 lines (36 loc) · 1.37 KB
/
Client.java
File metadata and controls
43 lines (36 loc) · 1.37 KB
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
package async_example;
import javax.jms.JMSException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
/**
* @author Igor Polevoy on 2/12/16.
*/
public class Client {
private static final Integer THREAD_COUNT = 10;
private static final Integer MESSAGE_COUNT = 10000;
private static final boolean BINARY_MODE = false;
public static void main(String[] args) throws IOException, JMSException {
String content = new String (Files.readAllBytes(Paths.get("src/main/resources/content.txt")));
for(int x = 0; x < THREAD_COUNT; x++){
Thread t = new Thread(){
@Override
public void run() {
try(RemoteMessagingClient client = new RemoteMessagingClient(BINARY_MODE)) {
System.out.println("Starting thread: " + getId());
for (int i = 0; i < MESSAGE_COUNT; i++){
try {
client.send(new ExampleCommand(content), "Mail", null);
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
t.start();
}
}
}