Search in sources :

Example 6 with DefaultMessageConsumer

use of com.generallycloud.baseio.container.jms.client.impl.DefaultMessageConsumer in project baseio by generallycloud.

the class TestSubscribe method test.

private static void test() throws Exception {
    LoggerFactory.configure();
    SimpleIoEventHandle eventHandle = new SimpleIoEventHandle();
    ServerConfiguration configuration = new ServerConfiguration(8300);
    SocketChannelContext context = new NioSocketChannelContext(configuration);
    SocketChannelConnector connector = new SocketChannelConnector(context);
    context.setIoEventHandleAdaptor(eventHandle);
    context.setProtocolFactory(new ProtobaseProtocolFactory());
    context.addSessionEventListener(new LoggerSocketSEListener());
    FixedSession session = new FixedSession(connector.connect());
    session.login("admin", "admin100");
    MessageConsumer consumer = new DefaultMessageConsumer(session);
    consumer.subscribe(new OnMessage() {

        @Override
        public void onReceive(Message message) {
            System.out.println(message);
        }
    });
    connector.close();
}
Also used : SocketChannelConnector(com.generallycloud.baseio.connector.SocketChannelConnector) DefaultMessageConsumer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageConsumer) MessageConsumer(com.generallycloud.baseio.container.jms.client.MessageConsumer) LoggerSocketSEListener(com.generallycloud.baseio.component.LoggerSocketSEListener) OnMessage(com.generallycloud.baseio.container.jms.client.OnMessage) Message(com.generallycloud.baseio.container.jms.Message) ServerConfiguration(com.generallycloud.baseio.configuration.ServerConfiguration) FixedSession(com.generallycloud.baseio.container.FixedSession) DefaultMessageConsumer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageConsumer) OnMessage(com.generallycloud.baseio.container.jms.client.OnMessage) SimpleIoEventHandle(com.generallycloud.baseio.container.SimpleIoEventHandle) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) ProtobaseProtocolFactory(com.generallycloud.baseio.codec.protobase.ProtobaseProtocolFactory)

Aggregations

LoggerSocketSEListener (com.generallycloud.baseio.component.LoggerSocketSEListener)6 NioSocketChannelContext (com.generallycloud.baseio.component.NioSocketChannelContext)6 SocketChannelContext (com.generallycloud.baseio.component.SocketChannelContext)6 ServerConfiguration (com.generallycloud.baseio.configuration.ServerConfiguration)6 SocketChannelConnector (com.generallycloud.baseio.connector.SocketChannelConnector)6 FixedSession (com.generallycloud.baseio.container.FixedSession)6 SimpleIoEventHandle (com.generallycloud.baseio.container.SimpleIoEventHandle)6 MessageConsumer (com.generallycloud.baseio.container.jms.client.MessageConsumer)6 DefaultMessageConsumer (com.generallycloud.baseio.container.jms.client.impl.DefaultMessageConsumer)6 ProtobaseProtocolFactory (com.generallycloud.baseio.codec.protobase.ProtobaseProtocolFactory)5 Message (com.generallycloud.baseio.container.jms.Message)5 OnMessage (com.generallycloud.baseio.container.jms.client.OnMessage)5 ParamedProtobaseProtocolFactory (com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory)1 TextByteMessage (com.generallycloud.baseio.container.jms.TextByteMessage)1