Search in sources :

Example 6 with MQException

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

the class RTPClient method setRTPHandle.

public void setRTPHandle(final RTPHandle handle) throws RTPException {
    if (this.handle != null) {
        return;
    }
    this.consumer.listen("invite", new OnMappedMessage() {

        @Override
        public void onReceive(MapMessage message) {
            handle.onInvite(RTPClient.this, message);
        }
    });
    this.consumer.listen("invite-reply", new OnMappedMessage() {

        @Override
        public void onReceive(MapMessage message) {
            handle.onInviteReplyed(RTPClient.this, message);
        }
    });
    this.consumer.listen("break", new OnMappedMessage() {

        @Override
        public void onReceive(MapMessage message) {
            handle.onBreak(RTPClient.this, message);
        }
    });
    this.handle = handle;
    try {
        this.consumer.receive(null);
    } catch (MQException e) {
        throw new RTPException(e);
    }
}
Also used : MQException(com.generallycloud.baseio.container.jms.MQException) OnMappedMessage(com.generallycloud.baseio.container.jms.client.impl.OnMappedMessage) MapMessage(com.generallycloud.baseio.container.jms.MapMessage) RTPException(com.generallycloud.baseio.container.rtp.RTPException)

Example 7 with MQException

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

the class RTPClient method inviteCustomer.

public void inviteCustomer(String inviteUsername) throws RTPException {
    if (roomId == null) {
        throw new RTPException("none roomId,create room first");
    }
    Authority authority = session.getAuthority();
    if (authority == null) {
        throw new RTPException("not login");
    }
    MapMessage message = new MapMessage("msgId", inviteUsername);
    message.put("eventName", "invite");
    message.put("roomId", roomId);
    message.put("inviteUsername", authority.getUsername());
    try {
        producer.offer(message);
    } catch (MQException e) {
        throw new RTPException(e);
    }
    this.inviteUsername = inviteUsername;
}
Also used : MQException(com.generallycloud.baseio.container.jms.MQException) Authority(com.generallycloud.baseio.container.authority.Authority) RTPException(com.generallycloud.baseio.container.rtp.RTPException) MapMessage(com.generallycloud.baseio.container.jms.MapMessage)

Example 8 with MQException

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

the class RTPClient method inviteReply.

public void inviteReply(String inviteUsername, int markinterval, long currentMark, int groupSize) throws RTPException {
    MapMessage message = new MapMessage("msgId", inviteUsername);
    message.put("eventName", "invite-reply");
    message.put(MARK_INTERVAL, markinterval);
    message.put(CURRENT_MARK, currentMark);
    message.put(GROUP_SIZE, groupSize);
    try {
        producer.offer(message);
    } catch (MQException e) {
        throw new RTPException(e);
    }
    this.inviteUsername = inviteUsername;
}
Also used : MQException(com.generallycloud.baseio.container.jms.MQException) MapMessage(com.generallycloud.baseio.container.jms.MapMessage) RTPException(com.generallycloud.baseio.container.rtp.RTPException)

Example 9 with MQException

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

the class DefaultMessageBrowser method browser.

@Override
public Message browser(String messageId) throws MQException {
    JSONObject param = new JSONObject();
    param.put("messageId", messageId);
    param.put("cmd", MQBrowserServlet.BROWSER);
    ParamedProtobaseFuture future;
    try {
        future = session.request(SERVICE_NAME, param.toJSONString());
    } catch (IOException e) {
        throw new MQException(e.getMessage(), e);
    }
    return messageDecoder.decode(future);
}
Also used : MQException(com.generallycloud.baseio.container.jms.MQException) JSONObject(com.alibaba.fastjson.JSONObject) IOException(java.io.IOException) ParamedProtobaseFuture(com.generallycloud.baseio.codec.protobase.future.ParamedProtobaseFuture)

Example 10 with MQException

use of com.generallycloud.baseio.container.jms.MQException 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

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