javax.jms.Message.setLongProperty()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(234)

本文整理了Java中javax.jms.Message.setLongProperty()方法的一些代码示例,展示了Message.setLongProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setLongProperty()方法的具体详情如下:
包路径:javax.jms.Message
类名称:Message
方法名:setLongProperty

Message.setLongProperty介绍

[英]Sets a long property value with the specified name into the message.
[中]在消息中设置具有指定名称的长属性值。

代码示例

代码示例来源:origin: apache/nifi

  1. message.setShortProperty(jmsPropName, Short.parseShort(value));
  2. } else if (type.equalsIgnoreCase(PROP_TYPE_LONG)) {
  3. message.setLongProperty(jmsPropName, Long.parseLong(value));
  4. } else if (type.equalsIgnoreCase(PROP_TYPE_BYTE)) {
  5. message.setByteProperty(jmsPropName, Byte.parseByte(value));

代码示例来源:origin: org.apache.tomee/openejb-core

  1. @Override
  2. public void setLongProperty(final String name, final long value) throws JMSException {
  3. message.setLongProperty(name, value);
  4. }

代码示例来源:origin: org.jboss.jbossas/jboss-as-connector

  1. public void setLongProperty(String name, long value) throws JMSException
  2. {
  3. message.setLongProperty(name, value);
  4. }

代码示例来源:origin: com.centurylink.mdw/mdw-common

  1. public void setMessageDelay(QueueSender sender, Message message, long delaySeconds) throws JMSException {
  2. message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delaySeconds * 1000);
  3. }

代码示例来源:origin: org.jboss.genericjms/generic-jms-ra-jar

  1. public void setLongProperty(String name, long value) throws JMSException {
  2. message.setLongProperty(name, value);
  3. }

代码示例来源:origin: org.apache.qpid/qpid-jca

  1. /**
  2. * Set property
  3. * @param name The name
  4. * @param value The value
  5. * @exception JMSException Thrown if an error occurs
  6. */
  7. public void setLongProperty(final String name, final long value) throws JMSException
  8. {
  9. if (_log.isTraceEnabled())
  10. {
  11. _log.trace("setLongProperty(" + name + ", " + value + ")");
  12. }
  13. _message.setLongProperty(name, value);
  14. }

代码示例来源:origin: apache/activemq-artemis

  1. /**
  2. * Set property
  3. *
  4. * @param name The name
  5. * @param value The value
  6. * @throws JMSException Thrown if an error occurs
  7. */
  8. @Override
  9. public void setLongProperty(final String name, final long value) throws JMSException {
  10. if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
  11. ActiveMQRALogger.LOGGER.trace("setLongProperty(" + name + ", " + value + ")");
  12. }
  13. message.setLongProperty(name, value);
  14. }

代码示例来源:origin: org.apache.activemq/artemis-ra

  1. /**
  2. * Set property
  3. *
  4. * @param name The name
  5. * @param value The value
  6. * @throws JMSException Thrown if an error occurs
  7. */
  8. @Override
  9. public void setLongProperty(final String name, final long value) throws JMSException {
  10. if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
  11. ActiveMQRALogger.LOGGER.trace("setLongProperty(" + name + ", " + value + ")");
  12. }
  13. message.setLongProperty(name, value);
  14. }

代码示例来源:origin: apache/activemq-artemis

  1. public static Message sendMessageWithProperty(final Session session,
  2. final Destination destination,
  3. final String key,
  4. final long value) throws JMSException {
  5. MessageProducer producer = session.createProducer(destination);
  6. Message message = session.createMessage();
  7. message.setLongProperty(key, value);
  8. producer.send(message);
  9. return message;
  10. }

代码示例来源:origin: techa03/goodsKill

  1. @Override
  2. public Message createMessage(Session session) throws JMSException {
  3. Message message = session.createMessage();
  4. message.setLongProperty("seckillId", finalSeckillId);
  5. message.setBooleanProperty("status", true);
  6. message.setStringProperty("note", note);
  7. return message;
  8. }
  9. });

代码示例来源:origin: Nepxion/Thunder

  1. @Override
  2. public Message createMessage(Session session) throws JMSException {
  3. Message message = mqMessageConverter.toMessage(response, session);
  4. message.setBooleanProperty(ThunderConstant.ASYNC_ATTRIBUTE_NAME, response.isAsync());
  5. message.setLongProperty(ThunderConstant.TIMEOUT_ATTRIBUTE_NAME, response.getTimeout());
  6. MQSelectorUtil.setRequestSelector(message, selector);
  7. MQSelectorUtil.setResponseSelector(message, applicationEntity);
  8. return message;
  9. }
  10. });

代码示例来源:origin: apache/activemq-artemis

  1. /**
  2. * if a property is set as a <code>long</code>,
  3. * it can also be read as a <code>long</code>.
  4. */
  5. @Test
  6. public void testLong2Long() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. message.setLongProperty("prop", 127L);
  10. Assert.assertEquals(127L, message.getLongProperty("prop"));
  11. } catch (JMSException e) {
  12. fail(e);
  13. }
  14. }

代码示例来源:origin: apache/activemq-artemis

  1. /**
  2. * if a property is set as a <code>long</code>,
  3. * it can also be read as a <code>String</code>.
  4. */
  5. @Test
  6. public void testLong2String() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. message.setLongProperty("prop", 127L);
  10. Assert.assertEquals("127", message.getStringProperty("prop"));
  11. } catch (JMSException e) {
  12. fail(e);
  13. }
  14. }

代码示例来源:origin: apache/activemq-artemis

  1. private void sendMessageUsingOpenWire(String queueName) throws Exception {
  2. Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  3. ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
  4. System.out.println("destination: " + destination);
  5. final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
  6. javax.jms.Message message = session.createMessage();
  7. message.setBooleanProperty("booleanProperty", false);
  8. message.setLongProperty("longProperty", 99999L);
  9. message.setByteProperty("byteProperty", (byte) 5);
  10. message.setIntProperty("intProperty", 979);
  11. message.setShortProperty("shortProperty", (short) 1099);
  12. message.setStringProperty("stringProperty", "HelloMessage");
  13. producer.send(message);
  14. }

代码示例来源:origin: apache/activemq-artemis

  1. /**
  2. * if a property is set as a <code>long</code>,
  3. * to get is as a <code>byte</code> throws a <code>javax.jms.MessageFormatException</code>.
  4. */
  5. @Test
  6. public void testLong2Byte() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. // store a value that can't be converted to byte
  10. message.setLongProperty("prop", 127L);
  11. message.getByteProperty("prop");
  12. Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
  13. } catch (MessageFormatException e) {
  14. } catch (JMSException e) {
  15. fail(e);
  16. }
  17. }

代码示例来源:origin: apache/activemq-artemis

  1. /**
  2. * if a property is set as a <code>long</code>,
  3. * to get is as a <code>float</code> throws a <code>javax.jms.MessageFormatException</code>.
  4. */
  5. @Test
  6. public void testLong2Float() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. message.setLongProperty("prop", 127L);
  10. message.getFloatProperty("prop");
  11. Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
  12. } catch (MessageFormatException e) {
  13. } catch (JMSException e) {
  14. fail(e);
  15. }
  16. }

代码示例来源:origin: apache/activemq-artemis

  1. /**
  2. * if a property is set as a <code>long</code>,
  3. * to get is as an <code>int</code> throws a <code>javax.jms.MessageFormatException</code>.
  4. */
  5. @Test
  6. public void testLong2Int() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. message.setLongProperty("prop", 127L);
  10. message.getIntProperty("prop");
  11. Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
  12. } catch (MessageFormatException e) {
  13. } catch (JMSException e) {
  14. fail(e);
  15. }
  16. }

代码示例来源:origin: apache/activemq-artemis

  1. /**
  2. * if a property is set as a <code>long</code>,
  3. * to get is as a <code>double</code> throws a <code>javax.jms.MessageFormatException</code>.
  4. */
  5. @Test
  6. public void testLong2Double() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. message.setLongProperty("prop", 127L);
  10. message.getDoubleProperty("prop");
  11. Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
  12. } catch (MessageFormatException e) {
  13. } catch (JMSException e) {
  14. fail(e);
  15. }
  16. }

代码示例来源:origin: apache/activemq-artemis

  1. /**
  2. * if a property is set as a <code>long</code>,
  3. * to get is as a <code>boolean</code> throws a <code>javax.jms.MessageFormatException</code>.
  4. */
  5. @Test
  6. public void testLong2Boolean() {
  7. try {
  8. Message message = senderSession.createMessage();
  9. // store a value that can be converted to boolean
  10. message.setLongProperty("prop", 127L);
  11. message.getBooleanProperty("prop");
  12. Assert.fail("sec. 3.5.4 The unmarked cases [of Table 0-4] should raise a JMS MessageFormatException.\n");
  13. } catch (MessageFormatException e) {
  14. } catch (JMSException e) {
  15. fail(e);
  16. }
  17. }

代码示例来源:origin: apache/activemq-artemis

  1. protected void prepareMessage(final Message m) throws JMSException {
  2. m.setBooleanProperty("booleanProperty", true);
  3. m.setByteProperty("byteProperty", (byte) 3);
  4. m.setDoubleProperty("doubleProperty", 4.0);
  5. m.setFloatProperty("floatProperty", 5.0f);
  6. m.setIntProperty("intProperty", 6);
  7. m.setLongProperty("longProperty", 7);
  8. m.setShortProperty("shortProperty", (short) 8);
  9. m.setStringProperty("stringProperty", "this is a String property");
  10. m.setJMSCorrelationID("this is the correlation ID");
  11. m.setJMSReplyTo(ActiveMQServerTestCase.topic1);
  12. m.setJMSType("someArbitraryType");
  13. }

相关文章