Search in sources :

Example 1 with WaiterOnFuture

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);
    }
}
Also used : ProtobaseFuture(com.generallycloud.baseio.codec.protobase.future.ProtobaseFuture) MQException(com.generallycloud.baseio.container.jms.MQException) RESMessage(com.generallycloud.baseio.container.RESMessage) IOException(java.io.IOException) WaiterOnFuture(com.generallycloud.baseio.container.WaiterOnFuture)

Aggregations

ProtobaseFuture (com.generallycloud.baseio.codec.protobase.future.ProtobaseFuture)1 RESMessage (com.generallycloud.baseio.container.RESMessage)1 WaiterOnFuture (com.generallycloud.baseio.container.WaiterOnFuture)1 MQException (com.generallycloud.baseio.container.jms.MQException)1 IOException (java.io.IOException)1