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


Java MapMessage.setObject方法代码示例

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


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

示例1: sendCompressedMapMessageUsingOpenWire

import javax.jms.MapMessage; //导入方法依赖的package包/类
private void sendCompressedMapMessageUsingOpenWire() throws Exception {
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);

   final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);

   MapMessage mapMessage = session.createMapMessage();

   mapMessage.setBoolean("boolean-type", true);
   mapMessage.setByte("byte-type", (byte) 10);
   mapMessage.setBytes("bytes-type", TEXT.getBytes());
   mapMessage.setChar("char-type", 'A');
   mapMessage.setDouble("double-type", 55.3D);
   mapMessage.setFloat("float-type", 79.1F);
   mapMessage.setInt("int-type", 37);
   mapMessage.setLong("long-type", 56652L);
   mapMessage.setObject("object-type", new String("VVVV"));
   mapMessage.setShort("short-type", (short) 333);
   mapMessage.setString("string-type", TEXT);

   producer.send(mapMessage);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:CompressedInteropTest.java

示例2: createMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
@Override
protected Message createMessage(int index) throws JMSException {
   MapMessage answer = session.createMapMessage();

   answer.setString("textField", data[index]);

   Map<String, Object> grandChildMap = new HashMap<>();
   grandChildMap.put("x", "abc");
   grandChildMap.put("y", Arrays.asList(new Object[]{"a", "b", "c"}));

   Map<String, Object> nestedMap = new HashMap<>();
   nestedMap.put("a", "foo");
   nestedMap.put("b", Integer.valueOf(23));
   nestedMap.put("c", Long.valueOf(45));
   nestedMap.put("d", grandChildMap);

   answer.setObject("mapField", nestedMap);
   answer.setObject("listField", Arrays.asList(new Object[]{"a", "b", "c"}));

   return answer;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:NestedMapMessageTest.java

示例3: sendTestMapMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
private void sendTestMapMessage(ActiveMQConnectionFactory factory, String message) throws JMSException {
   ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(queue);
   MapMessage mapMessage = session.createMapMessage();

   mapMessage.setBoolean("boolean-type", true);
   mapMessage.setByte("byte-type", (byte) 10);
   mapMessage.setBytes("bytes-type", TEXT.getBytes());
   mapMessage.setChar("char-type", 'A');
   mapMessage.setDouble("double-type", 55.3D);
   mapMessage.setFloat("float-type", 79.1F);
   mapMessage.setInt("int-type", 37);
   mapMessage.setLong("long-type", 56652L);
   mapMessage.setObject("object-type", new String("VVVV"));
   mapMessage.setShort("short-type", (short) 333);
   mapMessage.setString("string-type", TEXT);

   producer.send(mapMessage);
   connection.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:MessageCompressionTest.java

示例4: prepareMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
@Override
protected void prepareMessage(final Message m) throws JMSException {
   super.prepareMessage(m);

   MapMessage mm = (MapMessage) m;

   mm.setBoolean("boolean", true);
   mm.setByte("byte", (byte) 3);
   mm.setBytes("bytes", new byte[]{(byte) 3, (byte) 4, (byte) 5});
   mm.setChar("char", (char) 6);
   mm.setDouble("double", 7.0);
   mm.setFloat("float", 8.0f);
   mm.setInt("int", 9);
   mm.setLong("long", 10L);
   mm.setObject("object", new String("this is an object"));
   mm.setShort("short", (short) 11);
   mm.setString("string", "this is a string");
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:19,代码来源:MapMessageTest.java

示例5: createMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
public MapMessage createMessage(Map<String, Object> body, Map<String, Object> properties) {
   MapMessage message = this.createMapMessage();

   if (body != null) {
      for (Map.Entry<String, Object> entry : body.entrySet()) {
         try {
            message.setObject(entry.getKey(), entry.getValue());
         } catch (JMSException jmsEx) {
            throw new EmbeddedJMSResourceException(String.format("Failed to set body entry {%s = %s} on MapMessage", entry.getKey(), entry.getValue().toString()), jmsEx);
         }
      }
   }

   setMessageProperties(message, properties);

   return message;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:EmbeddedJMSResource.java

示例6: send

import javax.jms.MapMessage; //导入方法依赖的package包/类
@Override
public JMSProducer send(Destination destination, Map<String, Object> body) {
    try {
        MapMessage message = session.createMapMessage();
        for (Map.Entry<String, Object> entry : body.entrySet()) {
            message.setObject(entry.getKey(), entry.getValue());
        }

        doSend(destination, message);
    } catch (JMSException jmse) {
        throw JMSExceptionSupport.createRuntimeException(jmse);
    }

    return this;
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:16,代码来源:MockJMSProducer.java

示例7: convertToMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
public static MapMessage convertToMessage(MapMessage mapMessage,Event event) throws JMSException{
	String name = event.getName();
	Object data = event.getData();
	// 如果已经是字符串,则不动
	String dataStr = null;
	if(!(data instanceof String)){
	     dataStr = JSON.toJSONString(data,SerializerFeature.WriteClassName);
	}else{
	    dataStr = data.toString();
	}
	mapMessage.setObject("name", name);
	mapMessage.setObject("data", dataStr);
	return mapMessage;
}
 
开发者ID:eXcellme,项目名称:eds,代码行数:15,代码来源:EventConverter.java

示例8: send

import javax.jms.MapMessage; //导入方法依赖的package包/类
@Override
public JMSProducer send(Destination destination, Map<String, Object> body) {
    try {
        MapMessage message = context.createMapMessage();
        for (Map.Entry<String, Object> entry : body.entrySet()) {
            message.setObject(entry.getKey(), entry.getValue());
        }
        doSend(destination, message);
    } catch (JMSException jmse) {
        throw Utils.convertToRuntimeException(jmse);
    }
    return this;
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:14,代码来源:JMSProducerImpl.java

示例9: createMessageForMap

import javax.jms.MapMessage; //导入方法依赖的package包/类
/**
 * Create a JMS MapMessage for the given Map.
 * @param map the Map to convert
 * @param session current JMS session
 * @return the resulting message
 * @throws JMSException if thrown by JMS methods
 * @see javax.jms.Session#createMapMessage
 */
protected MapMessage createMessageForMap(Map<?, ?> map, Session session) throws JMSException {
	MapMessage message = session.createMapMessage();
	for (Map.Entry<?, ?> entry : map.entrySet()) {
		if (!(entry.getKey() instanceof String)) {
			throw new MessageConversionException("Cannot convert non-String key of type [" +
					ObjectUtils.nullSafeClassName(entry.getKey()) + "] to JMS MapMessage entry");
		}
		message.setObject((String) entry.getKey(), entry.getValue());
	}
	return message;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:SimpleMessageConverter.java

示例10: publish

import javax.jms.MapMessage; //导入方法依赖的package包/类
public MapMessage publish(Map<String, Object> map, String destinationName, Map<String, Object> properties, 
        int deliveryMode, int priority, long expiration)
        throws JMSException, NamingException {
    MapMessage msg = session.createMapMessage();
    for (Entry<String, Object> me : map.entrySet()) {
        msg.setObject(me.getKey(), me.getValue());
    }
    return (MapMessage)setPropertiesAndSend(destinationName, properties, msg, deliveryMode, priority, expiration);
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:10,代码来源:Publisher.java

示例11: populateMapMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
/**
 * Populates a {@link MapMessage} from a {@link Map} instance.
 */
protected void populateMapMessage(MapMessage message, Map<?, ?> map, CamelContext context)
    throws JMSException {
    for (Entry<?, ?> entry : map.entrySet()) {
        String keyString = CamelContextHelper.convertTo(context, String.class, entry.getKey());
        if (keyString != null) {
            message.setObject(keyString, entry.getValue());
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:JmsBinding.java

示例12: populateMapMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
/**
 * Populates a {@link MapMessage} from a {@link Map} instance.
 */
protected void populateMapMessage(MapMessage message, Map<?, ?> map, CamelContext context)
        throws JMSException {
    for (Map.Entry<?, ?> entry : map.entrySet()) {
        String keyString = CamelContextHelper.convertTo(context, String.class, entry.getKey());
        if (keyString != null) {
            message.setObject(keyString, entry.getValue());
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:JmsBinding.java

示例13: createMessageForMap

import javax.jms.MapMessage; //导入方法依赖的package包/类
/**
 * Create a JMS MapMessage for the given Map.
 *
 * @param map the Map to convert
 * @return the resulting message
 * @throws JMSException if thrown by JMS methods
 */
private Message createMessageForMap(Map<?,?> map) throws JMSException
{
  MapMessage message = getSession().createMapMessage();
  for (Map.Entry<?,?> entry: map.entrySet()) {
    if (!(entry.getKey() instanceof String)) {
      throw new RuntimeException("Cannot convert non-String key of type ["
              + entry.getKey().getClass() + "] to JMS MapMessage entry");
    }
    message.setObject((String)entry.getKey(), entry.getValue());
  }
  return message;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:20,代码来源:JMSMultiPortOutputOperator.java

示例14: testResendWithLargeMessage

import javax.jms.MapMessage; //导入方法依赖的package包/类
@Test
public void testResendWithLargeMessage() throws Exception {
   conn = cf.createConnection();
   conn.start();

   Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
   ArrayList<Message> msgs = new ArrayList<>();

   for (int i = 0; i < 10; i++) {
      BytesMessage bm = sess.createBytesMessage();
      bm.setObjectProperty(ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM, ActiveMQTestBase.createFakeLargeStream(2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE));
      msgs.add(bm);

      MapMessage mm = sess.createMapMessage();
      mm.setBoolean("boolean", true);
      mm.setByte("byte", (byte) 3);
      mm.setBytes("bytes", new byte[]{(byte) 3, (byte) 4, (byte) 5});
      mm.setChar("char", (char) 6);
      mm.setDouble("double", 7.0);
      mm.setFloat("float", 8.0f);
      mm.setInt("int", 9);
      mm.setLong("long", 10L);
      mm.setObject("object", new String("this is an object"));
      mm.setShort("short", (short) 11);
      mm.setString("string", "this is a string");

      msgs.add(mm);
      msgs.add(sess.createTextMessage("hello" + i));
      msgs.add(sess.createObjectMessage(new SomeSerializable("hello" + i)));
   }

   internalTestResend(msgs, sess);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:34,代码来源:ReSendMessageTest.java

示例15: testResendWithMapMessagesOnly

import javax.jms.MapMessage; //导入方法依赖的package包/类
@Test
public void testResendWithMapMessagesOnly() throws Exception {
   conn = cf.createConnection();
   conn.start();

   Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
   ArrayList<Message> msgs = new ArrayList<>();

   for (int i = 0; i < 1; i++) {
      MapMessage mm = sess.createMapMessage();
      mm.setBoolean("boolean", true);
      mm.setByte("byte", (byte) 3);
      mm.setBytes("bytes", new byte[]{(byte) 3, (byte) 4, (byte) 5});
      mm.setChar("char", (char) 6);
      mm.setDouble("double", 7.0);
      mm.setFloat("float", 8.0f);
      mm.setInt("int", 9);
      mm.setLong("long", 10L);
      mm.setObject("object", new String("this is an object"));
      mm.setShort("short", (short) 11);
      mm.setString("string", "this is a string");

      msgs.add(mm);

      MapMessage emptyMap = sess.createMapMessage();
      msgs.add(emptyMap);
   }

   internalTestResend(msgs, sess);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:31,代码来源:ReSendMessageTest.java


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