Guest User

Untitled

a guest
Apr 30th, 2014
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. // Main class for pull socket
  2. public static void main(String[] args) throws InterruptedException {
  3.         ZMQ.Socket pull = ZMQ.context(1).socket(ZMQ.PULL);
  4.         pull.setHWM(1);
  5.         pull.bind("tcp://*:10000");
  6.         System.out.println("Pull socket started");
  7.         Thread.sleep(TimeUnit.MINUTES.toMillis(5));
  8. }
  9.  
  10. // Main class for push socket
  11. public static void main(String[] args) {
  12.         ZMQ.Socket push = ZMQ.context(1).socket(ZMQ.PUSH);
  13.         push.setHWM(1);
  14.         push.setSendTimeOut(1000);
  15.         push.connect("tcp://localhost:10000");
  16.         send(push, 10000000); // send 10 million messages
  17. }
  18.  
  19. private static void send(ZMQ.Socket socket, long times) {
  20.         for (int i = 0; i < times; i++) {
  21.             System.out.println("Try " + i + ": " + socket.send(TEST_MESSAGE.getBytes(), 0));
  22.         }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment