use of com.generallycloud.baseio.container.jms.client.OnMessage in project baseio by generallycloud.
the class TestTransaction method rollback.
static void rollback(MessageConsumer consumer) throws MQException {
long old = System.currentTimeMillis();
consumer.beginTransaction();
consumer.receive(new OnMessage() {
@Override
public void onReceive(Message message) {
System.out.println(message);
}
});
consumer.rollback();
System.out.println("Time:" + (System.currentTimeMillis() - old));
}
use of com.generallycloud.baseio.container.jms.client.OnMessage 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();
}
Aggregations