當前位置: 首頁>>代碼示例>>Java>>正文


Java MapMessage.setLong方法代碼示例

本文整理匯總了Java中javax.jms.MapMessage.setLong方法的典型用法代碼示例。如果您正苦於以下問題:Java MapMessage.setLong方法的具體用法?Java MapMessage.setLong怎麽用?Java MapMessage.setLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jms.MapMessage的用法示例。


在下文中一共展示了MapMessage.setLong方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: sendMapMessageUsingOpenWire

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

   System.out.println("destination: " + destination);
   final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);

   MapMessage mapMessage = session.createMapMessage();
   mapMessage.setBoolean("aboolean", true);
   mapMessage.setByte("abyte", (byte) 4);
   mapMessage.setBytes("abytes", new byte[]{4, 5});
   mapMessage.setChar("achar", 'a');
   mapMessage.setDouble("adouble", 4.4);
   mapMessage.setFloat("afloat", 4.5f);
   mapMessage.setInt("aint", 40);
   mapMessage.setLong("along", 80L);
   mapMessage.setShort("ashort", (short) 65);
   mapMessage.setString("astring", "hello");

   producer.send(mapMessage);
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:22,代碼來源:GeneralInteropTest.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: 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

示例6: 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

示例7: sendMapMessageUsingCoreJms

import javax.jms.MapMessage; //導入方法依賴的package包/類
private void sendMapMessageUsingCoreJms(String queueName) throws Exception {
   Connection jmsConn = null;
   try {
      jmsConn = coreCf.createConnection();
      Session session = jmsConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MapMessage mapMessage = session.createMapMessage();
      mapMessage.setBoolean("aboolean", true);
      mapMessage.setByte("abyte", (byte) 4);
      mapMessage.setBytes("abytes", new byte[]{4, 5});
      mapMessage.setChar("achar", 'a');
      mapMessage.setDouble("adouble", 4.4);
      mapMessage.setFloat("afloat", 4.5f);
      mapMessage.setInt("aint", 40);
      mapMessage.setLong("along", 80L);
      mapMessage.setShort("ashort", (short) 65);
      mapMessage.setString("astring", "hello");

      Queue queue = session.createQueue(queueName);
      MessageProducer producer = session.createProducer(queue);

      producer.send(mapMessage);
   } finally {
      if (jmsConn != null) {
         jmsConn.close();
      }
   }

}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:29,代碼來源:GeneralInteropTest.java

示例8: send

import javax.jms.MapMessage; //導入方法依賴的package包/類
@Override
public JMSProducer send(Destination destination, Map<String, Object> body) {
   MapMessage message = context.createMapMessage();
   if (body != null) {
      try {
         for (Entry<String, Object> entry : body.entrySet()) {
            final String name = entry.getKey();
            final Object v = entry.getValue();
            if (v instanceof String) {
               message.setString(name, (String) v);
            } else if (v instanceof Long) {
               message.setLong(name, (Long) v);
            } else if (v instanceof Double) {
               message.setDouble(name, (Double) v);
            } else if (v instanceof Integer) {
               message.setInt(name, (Integer) v);
            } else if (v instanceof Character) {
               message.setChar(name, (Character) v);
            } else if (v instanceof Short) {
               message.setShort(name, (Short) v);
            } else if (v instanceof Boolean) {
               message.setBoolean(name, (Boolean) v);
            } else if (v instanceof Float) {
               message.setFloat(name, (Float) v);
            } else if (v instanceof Byte) {
               message.setByte(name, (Byte) v);
            } else if (v instanceof byte[]) {
               byte[] array = (byte[]) v;
               message.setBytes(name, array, 0, array.length);
            } else {
               message.setObject(name, v);
            }
         }
      } catch (JMSException e) {
         throw new MessageFormatRuntimeException(e.getMessage());
      }
   }
   send(destination, message);
   return this;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:41,代碼來源:ActiveMQJMSProducer.java

示例9: marshal

import javax.jms.MapMessage; //導入方法依賴的package包/類
public Message marshal(EventBean eventBean, Session session,
                       long timestamp) throws EPException {
    EventType eventType = eventBean.getEventType();
    MapMessage mapMessage = null;
    try {
        mapMessage = session.createMapMessage();
        String[] properties = eventType.getPropertyNames();
        for (String property : properties) {
            if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled())) {
                log.debug(
                        ".Marshal EventProperty property==" + property + ", value=" +
                                eventBean.get(property));
            }
            Class clazz = eventType.getPropertyType(property);
            if (JavaClassHelper.isNumeric(clazz)) {
                Class boxedClazz = JavaClassHelper.getBoxedType(clazz);
                if (boxedClazz == Double.class) {
                    mapMessage.setDouble(property, (Double) eventBean.get(property));
                }
                if (boxedClazz == Float.class) {
                    mapMessage.setFloat(property, (Float) eventBean.get(property));
                }
                if (boxedClazz == Byte.class) {
                    mapMessage.setFloat(property, (Byte) eventBean.get(property));
                }
                if (boxedClazz == Short.class) {
                    mapMessage.setShort(property, (Short) eventBean.get(property));
                }
                if (boxedClazz == Integer.class) {
                    mapMessage.setInt(property, (Integer) eventBean.get(property));
                }
                if (boxedClazz == Long.class) {
                    mapMessage.setLong(property, (Long) eventBean.get(property));
                }
            } else if ((clazz == boolean.class) || (clazz == Boolean.class)) {
                mapMessage.setBoolean(property, (Boolean) eventBean.get(property));
            } else if ((clazz == Character.class) || (clazz == char.class)) {
                mapMessage.setChar(property, (Character) eventBean.get(property));
            } else if (clazz == String.class) {
                mapMessage.setString(property, (String) eventBean.get(property));
            } else {
                mapMessage.setObject(property, eventBean.get(property));
            }
        }
        mapMessage.setJMSTimestamp(timestamp);
    } catch (JMSException ex) {
        throw new EPException(ex);
    }
    return mapMessage;
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:51,代碼來源:JMSDefaultMapMessageMarshaller.java

示例10: createBodySendAndReceive

import javax.jms.MapMessage; //導入方法依賴的package包/類
/**
 * @param type
 * @throws JMSException
 */
private Object createBodySendAndReceive(JmsMessageType type) throws JMSException {
   Object res = null;
   Message msg = null;
   switch (type) {
      case BYTE:
         BytesMessage mByte = queueProducerSession.createBytesMessage();
         final int size = 20;
         byte[] resByte = new byte[size];
         for (int i = 0; i < size; i++) {
            resByte[i] = (byte) i;
            mByte.writeByte((byte) i);
         }
         msg = mByte;
         res = resByte;
         break;
      case TEXT:
         res = "JMS2";
         msg = queueProducerSession.createTextMessage("JMS2");
         break;
      case STREAM:
         msg = queueProducerSession.createStreamMessage();
         break;
      case OBJECT:
         res = new Double(37.6);
         msg = queueProducerSession.createObjectMessage(new Double(37.6));
         break;
      case MAP:
         MapMessage msg1 = queueProducerSession.createMapMessage();
         msg1.setInt("int", 13);
         msg1.setLong("long", 37L);
         msg1.setString("string", "crocodile");
         msg = msg1;
         Map<String, Object> map = new HashMap<>();
         map.put("int", Integer.valueOf(13));
         map.put("long", Long.valueOf(37L));
         map.put("string", "crocodile");
         res = map;
         break;
      default:
         Assert.fail("no default...");
   }
   Assert.assertNotNull(msg);
   msg.setStringProperty("type", type.toString());
   queueProducer.send(msg);
   return res;
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:51,代碼來源:BodyIsAssignableFromTest.java


注:本文中的javax.jms.MapMessage.setLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。