javax.jms.MessageFormatRuntimeException Java Examples

The following examples show how to use javax.jms.MessageFormatRuntimeException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JMSContextTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testJMSContextConsumerThrowsMessageFormatExceptionOnMalformedBody() throws Exception {
   Queue queue = createQueue(true, "ContextMalformedBodyTestQueue");

   JMSContext context = qraConnectionFactory.createContext();
   JMSProducer producer = context.createProducer();

   TextMessage message = context.createTextMessage("TestMessage");
   producer.send(queue, message);

   JMSConsumer consumer = context.createConsumer(queue);

   try {
      consumer.receiveBody(Boolean.class);
      fail("Should thrown MessageFormatException");
   } catch (MessageFormatRuntimeException mfre) {
      // Do nothing test passed
   } catch (Exception e) {
      fail("Threw wrong exception, should be MessageFormatRuntimeException, instead got: " + e.getClass().getCanonicalName());
   }
}
 
Example #2
Source File: JmsProducerTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@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.
   }
}
 
Example #3
Source File: JMS2.java    From tomee with Apache License 2.0 5 votes vote down vote up
public static JMSRuntimeException toRuntimeException(final 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);
}
 
Example #4
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@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());
   }
}
 
Example #5
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@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());
   }
}
 
Example #6
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public Set<String> getPropertyNames() {
   try {
      return properties.getMapNames();
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   } catch (RuntimeException e) {
      throw new JMSRuntimeException(e.getMessage());
   }
}
 
Example #7
Source File: JmsExceptionUtils.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #8
Source File: JmsProducerTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example #9
Source File: JmsProducerTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@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) {}
}
 
Example #10
Source File: JmsProducerTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendNullMessageThrowsMFRE() throws JMSException {
    JmsSession session = Mockito.mock(JmsSession.class);
    JmsMessageProducer messageProducer = Mockito.mock(JmsMessageProducer.class);

    JmsProducer producer = new JmsProducer(session, messageProducer);

    try {
        producer.send(JMS_DESTINATION, (Message) null);
        fail("Should throw a MessageFormatRuntimeException");
    } catch (MessageFormatRuntimeException mfre) {
    } catch (Exception e) {
        fail("Should throw a MessageFormatRuntimeException");
    }
}
 
Example #11
Source File: JMSConsumerIntegrationTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
public void doTestReceiveBodyFailsDoesNotAcceptMessage(int sessionMode) throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
        JMSContext context = testFixture.createJMSContext(testPeer);

        testPeer.expectBegin();

        final String content = "Message-Content";
        Queue queue = context.createQueue("myQueue");

        DescribedType amqpValueContent = new AmqpValueDescribedType(content);

        testPeer.expectReceiverAttach();
        testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueContent);
        testPeer.expectEnd();
        testPeer.expectClose();

        JMSConsumer messageConsumer = context.createConsumer(queue);
        try {
            messageConsumer.receiveBody(Boolean.class, 3000);
            fail("Should not read as Boolean type");
        } catch (MessageFormatRuntimeException mfre) {
        }

        context.close();

        testPeer.waitForAllHandlersToComplete(3000);
    }
}
 
Example #12
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public double getDoubleProperty(String name) {
   try {
      return properties.getDoubleProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
Example #13
Source File: JMSProducerImpl.java    From tomee with Apache License 2.0 5 votes vote down vote up
private <T> T getProperty(final String key, final Class<T> type) {
    final Object val = properties.get(key);
    if (val == null || type.isInstance(val)) {
        return type.cast(val);
    }
    try {
        return type.cast(propertyEditorRegistry.getValue(type, val.toString()));
    } catch (final PropertyEditorException pee) {
        throw new MessageFormatRuntimeException(pee.getMessage());
    }
}
 
Example #14
Source File: JMSProducerImpl.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public JMSProducer send(final Destination destination, final 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);
        }

        setProperties(message);
        if (completionListener != null) {
            producer.send(destination, message, completionListener);
        } else {
            producer.send(destination, message);
        }
    } catch (final JMSException e) {
        throw toRuntimeException(e);
    }
    return this;
}
 
Example #15
Source File: JMSProducerImpl.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public JMSProducer send(final Destination destination, final Map<String, Object> body) {
    final MapMessage message = wrap(context.createMapMessage());
    if (body != null) {
        try {
            for (final Map.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 (final JMSException e) {
            throw new MessageFormatRuntimeException(e.getMessage());
        }
    }
    send(destination, message);
    return this;
}
 
Example #16
Source File: JMSProducerImpl.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public JMSProducer send(final Destination destination, final byte[] body) {
    final BytesMessage message = wrap(context.createBytesMessage());
    if (body != null) {
        try {
            message.writeBytes(body);
        } catch (final JMSException e) {
            throw new MessageFormatRuntimeException(e.getMessage());
        }
    }
    send(destination, message);
    return this;
}
 
Example #17
Source File: JMSProducerImpl.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public JMSProducer setProperty(final String name, final Object value) {
    validName(name);
    if (value != null && !Boolean.class.isInstance(value) && !Byte.class.isInstance(value) && !Character.class.isInstance(value)
        && !Short.class.isInstance(value) && !Integer.class.isInstance(value) && !Long.class.isInstance(value)
        && !Float.class.isInstance(value) && !Double.class.isInstance(value) && !String.class.isInstance(value)
        && !byte[].class.isInstance(value)) {
        throw new MessageFormatRuntimeException("Unsupported type: " + value);
    }
    properties.put(name, value);
    return this;
}
 
Example #18
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public JMSProducer send(Destination destination, byte[] body) {
   BytesMessage message = context.createBytesMessage();
   if (body != null) {
      try {
         message.writeBytes(body);
      } catch (JMSException e) {
         throw new MessageFormatRuntimeException(e.getMessage());
      }
   }
   send(destination, message);
   return this;
}
 
Example #19
Source File: JmsPoolJMSProducerTest.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetObjectPropertyWithInvalidObject() {
    JMSProducer producer = context.createProducer();

    try {
        producer.setProperty(GOOD_PROPERTY_NAME, UUID.randomUUID());
        fail("Should not accept invalid property name");
    } catch (MessageFormatRuntimeException mfre) {}
}
 
Example #20
Source File: JmsPoolJMSProducerTest.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@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");
    }
}
 
Example #21
Source File: JmsContextTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvalidMessage() {
   JMSProducer producer = context.createProducer();
   try {
      producer.send(queue1, (Message) null);
      Assert.fail("null msg");
   } catch (MessageFormatRuntimeException expected) {
      // no-op
   }
}
 
Example #22
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #23
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #24
Source File: JmsPoolJMSProducerTest.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example #25
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #26
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@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());
   }
}
 
Example #27
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public byte getByteProperty(String name) {
   try {
      return properties.getByteProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
Example #28
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public short getShortProperty(String name) {
   try {
      return properties.getShortProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
Example #29
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public int getIntProperty(String name) {
   try {
      return properties.getIntProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}
 
Example #30
Source File: ActiveMQJMSProducer.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public long getLongProperty(String name) {
   try {
      return properties.getLongProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
   }
}