use of com.generallycloud.baseio.container.jms.Message in project baseio by generallycloud.
the class ConsumerOnFuture method onResponse.
@Override
public void onResponse(SocketSession session, Future future) {
ParamedProtobaseFuture f = (ParamedProtobaseFuture) future;
try {
Message message = messageDecoder.decode(f);
onMessage.onReceive(message);
} catch (MQException e) {
DebugUtil.debug(e);
}
}
use of com.generallycloud.baseio.container.jms.Message in project baseio by generallycloud.
the class BrowserExecutable method exec.
@Override
public CmdResponse exec(CommandContext context, HashMap<String, String> params) {
CmdResponse response = new CmdResponse();
MessageBrowser browser = getMessageBrowser(context);
if (browser == null) {
response.setResponse("请先登录!");
return response;
}
String messageId = params.get("-mid");
if (StringUtil.isNullOrBlank(messageId)) {
response.setResponse("参数不正确!\n" + "example:\n" + "browser -mid:mid");
return response;
}
try {
Message message = browser.browser(messageId);
if (message == null) {
response.setResponse("没有此id的消息!");
} else {
response.setResponse(message.toString());
}
} catch (Exception e) {
logger.debug(e);
}
return response;
}
use of com.generallycloud.baseio.container.jms.Message in project baseio by generallycloud.
the class MQBrowserServlet method doAccept.
@Override
public void doAccept(SocketSession session, ParamedProtobaseFuture future, MQSessionAttachment attachment) throws Exception {
Parameters param = future.getParameters();
String messageId = param.getParameter("messageId");
Message message = NullMessage.NULL_MESSAGE;
MQContext context = getMQContext();
String cmd = param.getParameter("cmd");
if (StringUtil.isNullOrBlank(cmd)) {
message = ErrorMessage.CMD_NOT_FOUND_MESSAGE;
} else {
if (SIZE.equals(cmd)) {
future.write(String.valueOf(context.messageSize()));
} else if (BROWSER.equals(cmd)) {
if (!StringUtil.isNullOrBlank(messageId)) {
message = context.browser(messageId);
if (message == null) {
message = NullMessage.NULL_MESSAGE;
future.write(message.toString());
} else {
int msgType = message.getMsgType();
String content = message.toString();
future.write(content);
if (msgType == 3) {
TextByteMessage byteMessage = (TextByteMessage) message;
byte[] bytes = byteMessage.getByteArray();
future.writeBinary(bytes);
}
}
}
} else if (ONLINE.equals(cmd)) {
boolean bool = context.isOnLine(param.getParameter("queueName"));
future.write(String.valueOf(bool));
}
}
session.flush(future);
}
use of com.generallycloud.baseio.container.jms.Message 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.Message 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