use of com.generallycloud.baseio.container.WaiterOnFuture in project baseio by generallycloud.
the class DefaultMessageConsumer method transactionVal.
private boolean transactionVal(String action) throws MQException {
try {
WaiterOnFuture onReadFuture = new WaiterOnFuture();
session.listen(MQTransactionServlet.SERVICE_NAME, onReadFuture);
session.write(MQTransactionServlet.SERVICE_NAME, action);
if (onReadFuture.await(3000)) {
throw MQException.TIME_OUT;
}
ProtobaseFuture future = (ProtobaseFuture) onReadFuture.getReadFuture();
RESMessage message = RESMessageDecoder.decode(future.getReadText());
if (message.getCode() == 0) {
return true;
} else {
throw new MQException(message.getDescription());
}
} catch (IOException e) {
throw new MQException(e.getMessage(), e);
}
}
Aggregations