gateway.addMessageListener(new IDontNeedSecurity());
gateway.addMessageListener(new ClientMessageValidationListener());
MinaConnectedMessageListener cml = new MinaConnectedMessageListener();
cml.setHeartbeatContainer(heartbeatContainer);
cml.setGateway(gateway);
gateway.addMessageListener(cml);
MinaDisconnectListenerAndInterceptor disconnect = new MinaDisconnectListenerAndInterceptor();
disconnect.setCloseOnDisconnectMessage(false);
gateway.addMessageListener(disconnect);