• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MessageFormatRuntimeException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.jms.MessageFormatRuntimeException的典型用法代码示例。如果您正苦于以下问题:Java MessageFormatRuntimeException类的具体用法?Java MessageFormatRuntimeException怎么用?Java MessageFormatRuntimeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: testSetters

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Test
public void testSetters() {
   long v = random.nextLong();
   producer.setDeliveryDelay(v);
   Assert.assertEquals(v, producer.getDeliveryDelay());

   long l = random.nextLong();
   producer.setTimeToLive(l);
   Assert.assertEquals(l, producer.getTimeToLive());

   String id = "ID: jms2-tests-correlation-id" + random.nextLong();
   producer.setJMSCorrelationID(id);
   Assert.assertEquals(id, producer.getJMSCorrelationID());

   //set a property of an invalid type (ArrayList)
   try {
      producer.setProperty("name1", new ArrayList<String>(2));
      fail("didn't get expected MessageFormatRuntimeException");
   } catch (MessageFormatRuntimeException e) {
      //expected.
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:JmsProducerTest.java


示例2: getPropertyNames

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public Set<String> getPropertyNames() {
   try {
      Set<SimpleString> simplePropNames = properties.getPropertyNames();
      Set<String> propNames = new HashSet<>(simplePropNames.size());

      for (SimpleString str : simplePropNames) {
         propNames.add(str.toString());
      }
      return propNames;
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   } catch (RuntimeException e) {
      throw new JMSRuntimeException(e.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:17,代码来源:ActiveMQJMSProducer.java


示例3: testSetPropertyConversions

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Test
public void testSetPropertyConversions() {
    JMSProducer producer = context.createProducer();

    producer.setProperty(STRING_PROPERTY_NAME, STRING_PROPERTY_VALUE);
    producer.setProperty(BYTE_PROPERTY_NAME, Byte.valueOf(BYTE_PROPERTY_VALUE));
    producer.setProperty(BOOLEAN_PROPERTY_NAME, Boolean.valueOf(BOOLEAN_PROPERTY_VALUE));
    producer.setProperty(SHORT_PROPERTY_NAME, Short.valueOf(SHORT_PROPERTY_VALUE));
    producer.setProperty(INTEGER_PROPERTY_NAME, Integer.valueOf(INTEGER_PROPERTY_VALUE));
    producer.setProperty(LONG_PROPERTY_NAME, Long.valueOf(LONG_PROPERTY_VALUE));
    producer.setProperty(FLOAT_PROPERTY_NAME, Float.valueOf(FLOAT_PROPERTY_VALUE));
    producer.setProperty(DOUBLE_PROPERTY_NAME, Double.valueOf(DOUBLE_PROPERTY_VALUE));

    try {
        producer.setProperty(STRING_PROPERTY_NAME, UUID.randomUUID());
        fail("Should not be able to set non-primitive type");
    } catch (MessageFormatRuntimeException mfe) {
    }

    assertNull(producer.getObjectProperty("Unknown"));

    assertEquals(STRING_PROPERTY_VALUE, producer.getStringProperty(STRING_PROPERTY_NAME));
    assertEquals(BYTE_PROPERTY_VALUE, producer.getByteProperty(BYTE_PROPERTY_NAME));
    assertEquals(BOOLEAN_PROPERTY_VALUE, producer.getBooleanProperty(BOOLEAN_PROPERTY_NAME));
    assertEquals(SHORT_PROPERTY_VALUE, producer.getShortProperty(SHORT_PROPERTY_NAME));
    assertEquals(INTEGER_PROPERTY_VALUE, producer.getIntProperty(INTEGER_PROPERTY_NAME));
    assertEquals(LONG_PROPERTY_VALUE, producer.getLongProperty(LONG_PROPERTY_NAME));
    assertEquals(FLOAT_PROPERTY_VALUE, producer.getFloatProperty(FLOAT_PROPERTY_NAME), 0.0);
    assertEquals(DOUBLE_PROPERTY_VALUE, producer.getDoubleProperty(DOUBLE_PROPERTY_NAME), 0.0);

    assertEquals(STRING_PROPERTY_VALUE, producer.getObjectProperty(STRING_PROPERTY_NAME));
    assertEquals(BYTE_PROPERTY_VALUE, producer.getObjectProperty(BYTE_PROPERTY_NAME));
    assertEquals(BOOLEAN_PROPERTY_VALUE, producer.getObjectProperty(BOOLEAN_PROPERTY_NAME));
    assertEquals(SHORT_PROPERTY_VALUE, producer.getObjectProperty(SHORT_PROPERTY_NAME));
    assertEquals(INTEGER_PROPERTY_VALUE, producer.getObjectProperty(INTEGER_PROPERTY_NAME));
    assertEquals(LONG_PROPERTY_VALUE, producer.getObjectProperty(LONG_PROPERTY_NAME));
    assertEquals(FLOAT_PROPERTY_VALUE, producer.getObjectProperty(FLOAT_PROPERTY_NAME));
    assertEquals(DOUBLE_PROPERTY_VALUE, producer.getObjectProperty(DOUBLE_PROPERTY_NAME));
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:40,代码来源:JmsPoolJMSProducerTest.java


示例4: testSetObjectPropetryWithInvalidObject

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Test
public void testSetObjectPropetryWithInvalidObject() {
    JMSProducer producer = context.createProducer();

    try {
        producer.setProperty(GOOD_PROPERTY_NAME, UUID.randomUUID());
        fail("Should not accept invalid property name");
    } catch (MessageFormatRuntimeException mfre) {}
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:10,代码来源:JmsPoolJMSProducerTest.java


示例5: testSendNullMessageThrowsMFRE

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Test
public void testSendNullMessageThrowsMFRE() throws JMSException {
    JMSProducer producer = context.createProducer();

    try {
        producer.send(JMS_DESTINATION, (Message) null);
        fail("Should throw a MessageFormatRuntimeException");
    } catch (MessageFormatRuntimeException mfre) {
    } catch (Exception e) {
        fail("Should throw a MessageFormatRuntimeException");
    }
}
 
开发者ID:messaginghub,项目名称:pooled-jms,代码行数:13,代码来源:JmsPoolJMSProducerTest.java


示例6: convertToRuntimeException

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
public static JMSRuntimeException convertToRuntimeException(JMSException e) {
    if (e instanceof javax.jms.IllegalStateException) {
        return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidClientIDException) {
        return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidDestinationException) {
        return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof InvalidSelectorException) {
        return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof JMSSecurityException) {
        return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageFormatException) {
        return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof MessageNotWriteableException) {
        return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof ResourceAllocationException) {
        return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionInProgressException) {
        return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    if (e instanceof TransactionRolledBackException) {
        return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e);
    }
    return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:34,代码来源:Utils.java


示例7: testInvalidMessage

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Test
public void testInvalidMessage() {
   JMSProducer producer = context.createProducer();
   try {
      producer.send(queue1, (Message) null);
      Assert.fail("null msg");
   } catch (MessageFormatRuntimeException expected) {
      // no-op
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:JmsContextTest.java


示例8: send

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public JMSProducer send(Destination destination, Message message) {
   if (message == null) {
      throw new MessageFormatRuntimeException("null message");
   }

   try {
      if (jmsHeaderCorrelationID != null) {
         message.setJMSCorrelationID(jmsHeaderCorrelationID);
      }
      if (jmsHeaderCorrelationIDAsBytes != null && jmsHeaderCorrelationIDAsBytes.length > 0) {
         message.setJMSCorrelationIDAsBytes(jmsHeaderCorrelationIDAsBytes);
      }
      if (jmsHeaderReplyTo != null) {
         message.setJMSReplyTo(jmsHeaderReplyTo);
      }
      if (jmsHeaderType != null) {
         message.setJMSType(jmsHeaderType);
      }
      // XXX HORNETQ-1209 "JMS 2.0" can this be a foreign msg?
      // if so, then "SimpleString" properties will trigger an error.
      setProperties(message);
      if (completionListener != null) {
         CompletionListener wrapped = new CompletionListenerWrapper(completionListener);
         producer.send(destination, message, wrapped);
      } else {
         producer.send(destination, message);
      }
   } catch (JMSException e) {
      throw JmsExceptionUtils.convertToRuntimeException(e);
   }
   return this;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:34,代码来源:ActiveMQJMSProducer.java


示例9: setProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public JMSProducer setProperty(String name, Object value) {
   checkName(name);
   try {
      TypedProperties.setObjectProperty(new SimpleString(name), value, properties);
   } catch (ActiveMQPropertyConversionException amqe) {
      throw new MessageFormatRuntimeException(amqe.getMessage());
   } catch (RuntimeException e) {
      throw new JMSRuntimeException(e.getMessage());
   }
   return this;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:13,代码来源:ActiveMQJMSProducer.java


示例10: getBooleanProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public boolean getBooleanProperty(String name) {
   try {
      return properties.getBooleanProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   } catch (RuntimeException e) {
      throw new JMSRuntimeException(e.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:ActiveMQJMSProducer.java


示例11: getByteProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public byte getByteProperty(String name) {
   try {
      return properties.getByteProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:ActiveMQJMSProducer.java


示例12: getShortProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public short getShortProperty(String name) {
   try {
      return properties.getShortProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:ActiveMQJMSProducer.java


示例13: getIntProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public int getIntProperty(String name) {
   try {
      return properties.getIntProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:ActiveMQJMSProducer.java


示例14: getLongProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public long getLongProperty(String name) {
   try {
      return properties.getLongProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:ActiveMQJMSProducer.java


示例15: getFloatProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public float getFloatProperty(String name) {
   try {
      return properties.getFloatProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:ActiveMQJMSProducer.java


示例16: getDoubleProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public double getDoubleProperty(String name) {
   try {
      return properties.getDoubleProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:9,代码来源:ActiveMQJMSProducer.java


示例17: getStringProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public String getStringProperty(String name) {
   try {
      SimpleString prop = properties.getSimpleStringProperty(new SimpleString(name));
      if (prop == null)
         return null;
      return prop.toString();
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   } catch (RuntimeException e) {
      throw new JMSRuntimeException(e.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:14,代码来源:ActiveMQJMSProducer.java


示例18: getObjectProperty

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
@Override
public Object getObjectProperty(String name) {
   try {
      SimpleString key = new SimpleString(name);
      Object property = properties.getProperty(key);
      if (stringPropertyNames.contains(key)) {
         property = property.toString();
      }
      return property;
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   } catch (RuntimeException e) {
      throw new JMSRuntimeException(e.getMessage());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:16,代码来源:ActiveMQJMSProducer.java


示例19: convertToRuntimeException

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
/**
 * Converts instances of sub-classes of {@link JMSException} into the corresponding sub-class of
 * {@link JMSRuntimeException}.
 *
 * @param e
 * @return
 */
public static JMSRuntimeException convertToRuntimeException(JMSException e) {
   if (e instanceof javax.jms.IllegalStateException) {
      return new IllegalStateRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof InvalidClientIDException) {
      return new InvalidClientIDRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof InvalidDestinationException) {
      return new InvalidDestinationRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof InvalidSelectorException) {
      return new InvalidSelectorRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof JMSSecurityException) {
      return new JMSSecurityRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof MessageFormatException) {
      return new MessageFormatRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof MessageNotWriteableException) {
      return new MessageNotWriteableRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof ResourceAllocationException) {
      return new ResourceAllocationRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof TransactionInProgressException) {
      return new TransactionInProgressRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   if (e instanceof TransactionRolledBackException) {
      return new TransactionRolledBackRuntimeException(e.getMessage(), e.getErrorCode(), e);
   }
   return new JMSRuntimeException(e.getMessage(), e.getErrorCode(), e);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:41,代码来源:JmsExceptionUtils.java


示例20: castTo

import javax.jms.MessageFormatRuntimeException; //导入依赖的package包/类
public  static  <T> T castTo(Class<T> c, Message message) throws JMSException {
    if (message == null) {
        throw new MessageFormatRuntimeException("empty body");
    }

    if (!isBodyAssignableTo(message, c)) {
        throw new MessageFormatRuntimeException("the message body cannot be assigned to the specified type "
                + c
                + " and the Message type "
                + StreamMessage.class
                + " cannot be used");
    }

    if (message instanceof ObjectMessage) {
        return c.cast(((ObjectMessage) message).getObject());
    } else if (message instanceof MapMessage) {
        return c.cast(resolveMapMessage((MapMessage) message));
    } else if (message instanceof BytesMessage) {
        BytesMessage bytesMessage = (BytesMessage) message;
        bytesMessage.reset();
        try {
            byte[] bytes = new byte[(int) bytesMessage.getBodyLength()];
            for (int i = 0; i < bytes.length; i++) {
                bytes[i] = bytesMessage.readByte();
            }
            return c.cast(bytes);
        } finally {
            bytesMessage.reset();
        }
    } else if (message instanceof TextMessage) {
        return c.cast(((TextMessage) message).getText());
    } else {
        throw new MessageFormatRuntimeException("internal error. unknown message type "
                + message.getClass() + " or empty body");
    }
}
 
开发者ID:Tibor17,项目名称:javaee-samples,代码行数:37,代码来源:Util.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IndexQuery类代码示例发布时间:2022-05-22
下一篇:
Java ActionContext类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap