Last active
January 13, 2016 22:55
-
-
Save tylertreat-wf/6d0f0875992a11cd3979 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) throws Exception { | |
ConnectionFactory cf = new ConnectionFactory(Constants.DEFAULT_URL); | |
final Connection conn = cf.createConnection(); | |
conn.subscribe("foo", new MessageHandler() { | |
@Override | |
public void onMessage(Message message) { | |
conn.publish("bar", "hello".getBytes()); | |
} | |
}); | |
for (int i = 0; i < 100000; i++) { | |
SyncSubscription sub = conn.subscribeSync("bar"); | |
sub.autoUnsubscribe(1); | |
conn.flush(); | |
conn.publish("foo", "test".getBytes()); | |
try { | |
System.out.println(sub.nextMessage(5000)); | |
} catch (TimeoutException e) { | |
System.out.println("got timeout " + i); | |
return; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment