当前位置: 首页>>代码示例>>Java>>正文


Java MapMessage.getObject方法代码示例

本文整理汇总了Java中javax.jms.MapMessage.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java MapMessage.getObject方法的具体用法?Java MapMessage.getObject怎么用?Java MapMessage.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jms.MapMessage的用法示例。


在下文中一共展示了MapMessage.getObject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: print

import javax.jms.MapMessage; //导入方法依赖的package包/类
public static void print(Message msg) throws JMSException {
    log.info(".print received message: " + msg.getJMSMessageID());
    if (msg instanceof ObjectMessage) {
        ObjectMessage objMsg = (ObjectMessage) msg;
        log.info(".print object: " + objMsg.getObject().toString());
    } else {
        MapMessage mapMsg = (MapMessage) msg;
        HashMap map = new HashMap();
        Enumeration en = mapMsg.getMapNames();
        while (en.hasMoreElements()) {
            String property = (String) en.nextElement();
            Object mapObject = mapMsg.getObject(property);
            map.put(property, mapObject);
        }
        log.info(".print map: " + map);
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:SupportJMSReceiver.java

示例2: createMapFromMapMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
/**
 * Extracts a {@link Map} from a {@link MapMessage}
 */
public Map<String, Object> createMapFromMapMessage(MapMessage message) throws JMSException {
    Map<String, Object> answer = new HashMap<String, Object>();
    Enumeration<?> names = message.getMapNames();
    while (names.hasMoreElements()) {
        String name = names.nextElement().toString();
        Object value = message.getObject(name);
        answer.put(name, value);
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:JmsBinding.java

示例3: receiveMapMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
private void receiveMapMessage(boolean useCore) throws Exception {
   MapMessage mapMessage = (MapMessage) receiveMessage(useCore);

   boolean booleanVal = mapMessage.getBoolean("boolean-type");
   assertTrue(booleanVal);
   byte byteVal = mapMessage.getByte("byte-type");
   assertEquals((byte) 10, byteVal);
   byte[] bytesVal = mapMessage.getBytes("bytes-type");
   byte[] originVal = TEXT.getBytes();
   assertEquals(originVal.length, bytesVal.length);
   for (int i = 0; i < bytesVal.length; i++) {
      assertTrue(bytesVal[i] == originVal[i]);
   }
   char charVal = mapMessage.getChar("char-type");
   assertEquals('A', charVal);
   double doubleVal = mapMessage.getDouble("double-type");
   assertEquals(55.3D, doubleVal, 0.1D);
   float floatVal = mapMessage.getFloat("float-type");
   assertEquals(79.1F, floatVal, 0.1F);
   int intVal = mapMessage.getInt("int-type");
   assertEquals(37, intVal);
   long longVal = mapMessage.getLong("long-type");
   assertEquals(56652L, longVal);
   Object objectVal = mapMessage.getObject("object-type");
   Object origVal = new String("VVVV");
   assertTrue(objectVal.equals(origVal));
   short shortVal = mapMessage.getShort("short-type");
   assertEquals((short) 333, shortVal);
   String strVal = mapMessage.getString("string-type");
   assertEquals(TEXT, strVal);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:32,代码来源:CompressedInteropTest.java

示例4: assertMessageValid

import javax.jms.MapMessage; //导入方法依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
protected void assertMessageValid(int index, Message message) throws JMSException {
   assertTrue("Should be a MapMessage: " + message, message instanceof MapMessage);

   MapMessage mapMessage = (MapMessage) message;

   Object value = mapMessage.getObject("textField");
   assertEquals("textField", data[index], value);

   Map map = (Map) mapMessage.getObject("mapField");
   assertNotNull(map);
   assertEquals("mapField.a", "foo", map.get("a"));
   assertEquals("mapField.b", Integer.valueOf(23), map.get("b"));
   assertEquals("mapField.c", Long.valueOf(45), map.get("c"));

   value = map.get("d");
   assertTrue("mapField.d should be a Map", value instanceof Map);
   map = (Map) value;

   assertEquals("mapField.d.x", "abc", map.get("x"));
   value = map.get("y");
   assertTrue("mapField.d.y is a List", value instanceof List);
   List list = (List) value;
   LOG.debug("mapField.d.y: " + list);
   assertEquals("listField.size", 3, list.size());

   LOG.debug("Found map: " + map);

   list = (List) mapMessage.getObject("listField");
   LOG.debug("listField: " + list);
   assertEquals("listField.size", 3, list.size());
   assertEquals("listField[0]", "a", list.get(0));
   assertEquals("listField[1]", "b", list.get(1));
   assertEquals("listField[2]", "c", list.get(2));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:37,代码来源:NestedMapMessageTest.java

示例5: ActiveMQMapMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
/**
 * Constructor for a foreign MapMessage
 *
 * @param foreign
 * @throws JMSException
 */
public ActiveMQMapMessage(final MapMessage foreign, final ClientSession session) throws JMSException {
   super(foreign, ActiveMQMapMessage.TYPE, session);
   Enumeration<?> names = foreign.getMapNames();
   while (names.hasMoreElements()) {
      String name = (String) names.nextElement();
      Object obj = foreign.getObject(name);
      setObject(name, obj);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:ActiveMQMapMessage.java

示例6: convertToEvent

import javax.jms.MapMessage; //导入方法依赖的package包/类
/**  
* extract message from mapMessage and convert to Event
* @throws JMSException if jms exception occured
*/
public static Event convertToEvent(MapMessage mapMessage) throws JMSException{
	Object data = mapMessage.getObject("data");
	Object name = mapMessage.getObject("name");
	return new Event(String.valueOf(name),data);
}
 
开发者ID:eXcellme,项目名称:eds,代码行数:10,代码来源:EventConverter.java

示例7: extractContent

import javax.jms.MapMessage; //导入方法依赖的package包/类
private void extractContent(StringBuilder buffer, StringBuilder propBuffer,
        Message msg, boolean isLast) {
    if (msg != null) {
        try {
            if (msg instanceof TextMessage){
                buffer.append(((TextMessage) msg).getText());
            } else if (msg instanceof ObjectMessage){
                ObjectMessage objectMessage = (ObjectMessage) msg;
                if(objectMessage.getObject() != null) {
                    buffer.append(objectMessage.getObject().getClass());
                } else {
                    buffer.append("object is null");
                }
            } else if (msg instanceof BytesMessage){
                BytesMessage bytesMessage = (BytesMessage) msg;
                buffer.append(bytesMessage.getBodyLength() + " bytes received in BytesMessage");
            } else if (msg instanceof MapMessage){
                MapMessage mapm = (MapMessage) msg;
                @SuppressWarnings("unchecked") // MapNames are Strings
                Enumeration<String> enumb = mapm.getMapNames();
                while(enumb.hasMoreElements()){
                    String name = enumb.nextElement();
                    Object obj = mapm.getObject(name);
                    buffer.append(name);
                    buffer.append(",");
                    buffer.append(obj.getClass().getCanonicalName());
                    buffer.append(",");
                    buffer.append(obj);
                    buffer.append("\n");
                }
            }
            Utils.messageProperties(propBuffer, msg);
            if(!isLast && !StringUtils.isEmpty(separator)) {
                propBuffer.append(separator);
                buffer.append(separator);
            }
        } catch (JMSException e) {
            log.error(e.getMessage());
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:42,代码来源:SubscriberSampler.java

示例8: unmarshal

import javax.jms.MapMessage; //导入方法依赖的package包/类
public EventBean unmarshal(EventAdapterService eventAdapterService,
                           Message message) throws EPException {
    try {
        if (message instanceof ObjectMessage) {
            ObjectMessage objmsg = (ObjectMessage) message;
            Serializable obj = objmsg.getObject();
            return eventAdapterService.adapterForBean(obj);
        } else if (message instanceof MapMessage) {
            Map<String, Object> properties = new HashMap<String, Object>();
            MapMessage mapMsg = (MapMessage) message;
            Enumeration en = mapMsg.getMapNames();
            while (en.hasMoreElements()) {
                String property = (String) en.nextElement();
                Object mapObject = mapMsg.getObject(property);
                properties.put(property, mapObject);
            }

            // Get event type property
            Object typeProperty = properties.get(InputAdapter.ESPERIO_MAP_EVENT_TYPE);
            if (typeProperty == null) {
                log.warn(".unmarshal Failed to unmarshal map message, expected type property not found: '" + InputAdapter.ESPERIO_MAP_EVENT_TYPE + "'");
                return null;
            }

            // Get event type
            String name = typeProperty.toString();
            EventType eventType = eventAdapterService.getExistsTypeByName(name);
            if (eventType == null) {
                log.warn(".unmarshal Failed to unmarshal map message, event type name '" + name + "' is not a known type");
                return null;
            }

            return eventAdapterService.adapterForTypedMap(properties, eventType);
        } else {
            String error = ".unmarshal Failed to unmarshal message of JMS type: " + message.getJMSType();
            log.error(error);
            throw new EPException(error);
        }
    } catch (JMSException ex) {
        throw new EPException("Error unmarshalling message", ex);
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:43,代码来源:JMSDefaultAnyMessageUnmarshaller.java


注:本文中的javax.jms.MapMessage.getObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。