Created
July 18, 2015 22:14
-
-
Save wagnerluis1982/2ef57e2540dbd08d374f 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 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