Search in sources :

Example 1 with MapByteMessage

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

the class FixedMessageConsumer method onReceive.

@Override
public void onReceive(Message message) {
    int msgType = message.getMsgType();
    if (Message.TYPE_MAP == msgType) {
        MapMessage m = (MapMessage) message;
        String eventName = m.getParameter("eventName");
        OnMappedMessage onMessage = onMappedMessages.get(eventName);
        if (onMessage == null) {
            return;
        }
        onMessage.onReceive(m);
    } else if (Message.TYPE_MAP_BYTE == msgType) {
        MapByteMessage m = (MapByteMessage) message;
        String eventName = m.getParameter("eventName");
        OnMappedMessage onMessage = onMappedMessages.get(eventName);
        if (onMessage == null) {
            return;
        }
        onMessage.onReceive(m);
    } else if (Message.TYPE_TEXT == msgType) {
        if (onTextMessage != null) {
            onTextMessage.onReceive((TextMessage) message);
        }
    } else if (Message.TYPE_TEXT_BYTE == msgType) {
        if (onTextByteMessage != null) {
            onTextByteMessage.onReceive((TextByteMessage) message);
        }
    } else if (Message.TYPE_ERROR == msgType) {
        if (onErrorMessage != null) {
            onErrorMessage.onReceive((ErrorMessage) message);
        }
    } else if (Message.TYPE_NULL == msgType) {
        if (onNullMessage != null) {
            onNullMessage.onReceive((NullMessage) message);
        }
    }
}
Also used : TextByteMessage(com.generallycloud.baseio.container.jms.TextByteMessage) NullMessage(com.generallycloud.baseio.container.jms.NullMessage) MapMessage(com.generallycloud.baseio.container.jms.MapMessage) MapByteMessage(com.generallycloud.baseio.container.jms.MapByteMessage)

Example 2 with MapByteMessage

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

the class MapByteMessageDecoder method decode.

@Override
public Message decode(ParamedProtobaseFuture future) {
    Parameters param = future.getParameters();
    String messageId = param.getParameter("msgId");
    String queueName = param.getParameter("queueName");
    JSONObject map = param.getJSONObject("map");
    byte[] array = future.getReadBinary();
    return new MapByteMessage(messageId, queueName, map, array);
}
Also used : Parameters(com.generallycloud.baseio.component.Parameters) JSONObject(com.alibaba.fastjson.JSONObject) MapByteMessage(com.generallycloud.baseio.container.jms.MapByteMessage)

Aggregations

MapByteMessage (com.generallycloud.baseio.container.jms.MapByteMessage)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Parameters (com.generallycloud.baseio.component.Parameters)1 MapMessage (com.generallycloud.baseio.container.jms.MapMessage)1 NullMessage (com.generallycloud.baseio.container.jms.NullMessage)1 TextByteMessage (com.generallycloud.baseio.container.jms.TextByteMessage)1