Search in sources :

Example 11 with MQException

use of com.generallycloud.baseio.container.jms.MQException in project baseio by generallycloud.

the class DefaultMessageProducer method offer.

private boolean offer(Message message, String serviceName) throws MQException {
    String param = message.toString();
    ProtobaseFuture future = null;
    int msgType = message.getMsgType();
    try {
        if (msgType == Message.TYPE_TEXT || msgType == Message.TYPE_MAP) {
            future = session.request(serviceName, param);
        } else if (msgType == Message.TYPE_TEXT_BYTE || msgType == Message.TYPE_MAP_BYTE) {
            BytedMessage _message = (BytedMessage) message;
            future = session.request(serviceName, param, _message.getByteArray());
        } else {
            throw new MQException("msgType:" + msgType);
        }
    } catch (IOException e) {
        throw new MQException(e.getMessage(), e);
    }
    String result = future.getReadText();
    if (result.length() == 1) {
        return "T".equals(result);
    }
    throw new MQException(result);
}
Also used : ProtobaseFuture(com.generallycloud.baseio.codec.protobase.future.ProtobaseFuture) MQException(com.generallycloud.baseio.container.jms.MQException) IOException(java.io.IOException) BytedMessage(com.generallycloud.baseio.container.jms.BytedMessage)

Aggregations

MQException (com.generallycloud.baseio.container.jms.MQException)11 IOException (java.io.IOException)7 ParamedProtobaseFuture (com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFuture)4 ProtobaseFuture (com.generallycloud.baseio.codec.protobase.future.ProtobaseFuture)4 MapMessage (com.generallycloud.baseio.container.jms.MapMessage)3 RTPException (com.generallycloud.baseio.container.rtp.RTPException)3 JSONObject (com.alibaba.fastjson.JSONObject)2 RESMessage (com.generallycloud.baseio.container.RESMessage)1 WaiterOnFuture (com.generallycloud.baseio.container.WaiterOnFuture)1 Authority (com.generallycloud.baseio.container.authority.Authority)1 BytedMessage (com.generallycloud.baseio.container.jms.BytedMessage)1 Message (com.generallycloud.baseio.container.jms.Message)1 OnMessage (com.generallycloud.baseio.container.jms.client.OnMessage)1 OnMappedMessage (com.generallycloud.baseio.container.jms.client.impl.OnMappedMessage)1