Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Main class for pull socket
- public static void main(String[] args) throws InterruptedException {
- ZMQ.Socket pull = ZMQ.context(1).socket(ZMQ.PULL);
- pull.setHWM(1);
- pull.bind("tcp://*:10000");
- System.out.println("Pull socket started");
- Thread.sleep(TimeUnit.MINUTES.toMillis(5));
- }
- // Main class for push socket
- public static void main(String[] args) {
- ZMQ.Socket push = ZMQ.context(1).socket(ZMQ.PUSH);
- push.setHWM(1);
- push.setSendTimeOut(1000);
- push.connect("tcp://localhost:10000");
- send(push, 10000000); // send 10 million messages
- }
- private static void send(ZMQ.Socket socket, long times) {
- for (int i = 0; i < times; i++) {
- System.out.println("Try " + i + ": " + socket.send(TEST_MESSAGE.getBytes(), 0));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment