Search in sources :

Example 1 with DefaultMessageProducer

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

the class TestTellerPower method main.

public static void main(String[] args) 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");
    MessageProducer producer = new DefaultMessageProducer(session);
    TextMessage message = new TextMessage("msgId", "qName", "你好!");
    long old = System.currentTimeMillis();
    for (int i = 0; i < 10000; i++) {
        producer.offer(message);
    }
    System.out.println("Time:" + (System.currentTimeMillis() - old));
    connector.close();
}
Also used : SocketChannelConnector(com.generallycloud.baseio.connector.SocketChannelConnector) DefaultMessageProducer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageProducer) LoggerSocketSEListener(com.generallycloud.baseio.component.LoggerSocketSEListener) ServerConfiguration(com.generallycloud.baseio.configuration.ServerConfiguration) FixedSession(com.generallycloud.baseio.container.FixedSession) SimpleIoEventHandle(com.generallycloud.baseio.container.SimpleIoEventHandle) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) ProtobaseProtocolFactory(com.generallycloud.baseio.codec.protobase.ProtobaseProtocolFactory) DefaultMessageProducer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageProducer) MessageProducer(com.generallycloud.baseio.container.jms.client.MessageProducer) TextMessage(com.generallycloud.baseio.container.jms.TextMessage)

Example 2 with DefaultMessageProducer

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

the class TestTellerByteMessage method main.

public static void main(String[] args) throws Exception {
    SimpleIoEventHandle eventHandle = new SimpleIoEventHandle();
    SocketChannelContext context = new NioSocketChannelContext(new ServerConfiguration(8300));
    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");
    MessageProducer producer = new DefaultMessageProducer(session);
    TextByteMessage message = new TextByteMessage("msgId", "uuid", "============", "你好!".getBytes(session.getContext().getEncoding()));
    long old = System.currentTimeMillis();
    for (int i = 0; i < 5; i++) {
        producer.offer(message);
    }
    System.out.println("Time:" + (System.currentTimeMillis() - old));
    connector.close();
}
Also used : TextByteMessage(com.generallycloud.baseio.container.jms.TextByteMessage) SocketChannelConnector(com.generallycloud.baseio.connector.SocketChannelConnector) DefaultMessageProducer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageProducer) LoggerSocketSEListener(com.generallycloud.baseio.component.LoggerSocketSEListener) ServerConfiguration(com.generallycloud.baseio.configuration.ServerConfiguration) FixedSession(com.generallycloud.baseio.container.FixedSession) SimpleIoEventHandle(com.generallycloud.baseio.container.SimpleIoEventHandle) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) ProtobaseProtocolFactory(com.generallycloud.baseio.codec.protobase.ProtobaseProtocolFactory) DefaultMessageProducer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageProducer) MessageProducer(com.generallycloud.baseio.container.jms.client.MessageProducer)

Example 3 with DefaultMessageProducer

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

the class TestPublish method main.

public static void main(String[] args) 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 ParamedProtobaseProtocolFactory());
    context.addSessionEventListener(new LoggerSocketSEListener());
    FixedSession session = new FixedSession(connector.connect());
    session.login("admin", "admin100");
    MessageProducer producer = new DefaultMessageProducer(session);
    TextMessage message = new TextMessage("msgId", "qName", "你好!");
    producer.publish(message);
    connector.close();
}
Also used : SocketChannelConnector(com.generallycloud.baseio.connector.SocketChannelConnector) DefaultMessageProducer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageProducer) LoggerSocketSEListener(com.generallycloud.baseio.component.LoggerSocketSEListener) ServerConfiguration(com.generallycloud.baseio.configuration.ServerConfiguration) FixedSession(com.generallycloud.baseio.container.FixedSession) DefaultMessageProducer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageProducer) MessageProducer(com.generallycloud.baseio.container.jms.client.MessageProducer) SimpleIoEventHandle(com.generallycloud.baseio.container.SimpleIoEventHandle) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) ParamedProtobaseProtocolFactory(com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory) TextMessage(com.generallycloud.baseio.container.jms.TextMessage) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext)

Example 4 with DefaultMessageProducer

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

the class TestTeller method main.

public static void main(String[] args) throws Exception {
    SimpleIoEventHandle eventHandle = new SimpleIoEventHandle();
    SocketChannelContext context = new NioSocketChannelContext(new ServerConfiguration(8300));
    SocketChannelConnector connector = new SocketChannelConnector(context);
    context.setIoEventHandleAdaptor(eventHandle);
    context.setProtocolFactory(new ParamedProtobaseProtocolFactory());
    context.addSessionEventListener(new LoggerSocketSEListener());
    FixedSession session = new FixedSession(connector.connect());
    boolean b = session.login("admin", "admin100");
    System.out.println(b);
    MessageProducer producer = new DefaultMessageProducer(session);
    TextMessage message = new TextMessage("msgId", "uuid", "你好!");
    MapMessage mapMessage = new MapMessage("msgId", "uuid");
    mapMessage.put("test", "test111111111111111111111");
    long old = System.currentTimeMillis();
    producer.offer(message);
    producer.offer(mapMessage);
    System.out.println("Time:" + (System.currentTimeMillis() - old));
    connector.close();
}
Also used : SocketChannelConnector(com.generallycloud.baseio.connector.SocketChannelConnector) DefaultMessageProducer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageProducer) LoggerSocketSEListener(com.generallycloud.baseio.component.LoggerSocketSEListener) ServerConfiguration(com.generallycloud.baseio.configuration.ServerConfiguration) MapMessage(com.generallycloud.baseio.container.jms.MapMessage) FixedSession(com.generallycloud.baseio.container.FixedSession) SimpleIoEventHandle(com.generallycloud.baseio.container.SimpleIoEventHandle) SocketChannelContext(com.generallycloud.baseio.component.SocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) NioSocketChannelContext(com.generallycloud.baseio.component.NioSocketChannelContext) DefaultMessageProducer(com.generallycloud.baseio.container.jms.client.impl.DefaultMessageProducer) MessageProducer(com.generallycloud.baseio.container.jms.client.MessageProducer) ParamedProtobaseProtocolFactory(com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory) TextMessage(com.generallycloud.baseio.container.jms.TextMessage)

Aggregations

LoggerSocketSEListener (com.generallycloud.baseio.component.LoggerSocketSEListener)4 NioSocketChannelContext (com.generallycloud.baseio.component.NioSocketChannelContext)4 SocketChannelContext (com.generallycloud.baseio.component.SocketChannelContext)4 ServerConfiguration (com.generallycloud.baseio.configuration.ServerConfiguration)4 SocketChannelConnector (com.generallycloud.baseio.connector.SocketChannelConnector)4 FixedSession (com.generallycloud.baseio.container.FixedSession)4 SimpleIoEventHandle (com.generallycloud.baseio.container.SimpleIoEventHandle)4 MessageProducer (com.generallycloud.baseio.container.jms.client.MessageProducer)4 DefaultMessageProducer (com.generallycloud.baseio.container.jms.client.impl.DefaultMessageProducer)4 TextMessage (com.generallycloud.baseio.container.jms.TextMessage)3 ParamedProtobaseProtocolFactory (com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory)2 ProtobaseProtocolFactory (com.generallycloud.baseio.codec.protobase.ProtobaseProtocolFactory)2 MapMessage (com.generallycloud.baseio.container.jms.MapMessage)1 TextByteMessage (com.generallycloud.baseio.container.jms.TextByteMessage)1