Skip to content

Instantly share code, notes, and snippets.

@wagnerluis1982
Created July 18, 2015 22:14
Show Gist options
  • Save wagnerluis1982/2ef57e2540dbd08d374f to your computer and use it in GitHub Desktop.
Save wagnerluis1982/2ef57e2540dbd08d374f to your computer and use it in GitHub Desktop.
public class MyInterceptor extends AbstractInterceptor {
private static PrintStream log;
static {
try {
final File f = new File("/tmp/moquette-subscribe-events.log");
log = new PrintStream(f);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
@Override
protected void handleIntercept(InterceptEvent evt) {
final AbstractMessage msg = ((ProtocolEvent) evt.getEvent()).getMessage();
if (msg instanceof PublishMessage) {
log.printf("PUB: %s\n", ((PublishMessage) msg).getTopicName());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
evt.executeHook();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment