ServerNettyMessageGateway gateway = new ServerNettyMessageGateway();
gateway.setPort(1234);
gateway.setHeartbeat(1000);
gateway.setAutoShutdown(true);
gateway.addHandler(new SimpleChannelUpstreamHandler() {
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
System.out.println("Session destroyed, exiting...");
System.exit(0);
}
});