Skip to content

Instantly share code, notes, and snippets.

@tylertreat-wf
Last active January 13, 2016 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylertreat-wf/6d0f0875992a11cd3979 to your computer and use it in GitHub Desktop.
Save tylertreat-wf/6d0f0875992a11cd3979 to your computer and use it in GitHub Desktop.
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