Java Code Examples for javax.jms.JMSException#getErrorCode()
The following examples show how to use
javax.jms.JMSException#getErrorCode() .
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: JmsExceptionThrowingFunction.java From ditto with Eclipse Public License 2.0 | 5 votes |
/** * Wraps a {@link org.eclipse.ditto.services.connectivity.messaging.amqp.JmsExceptionThrowingFunction} returning * a function by converting thrown {@link javax.jms.JMSException} to {@link javax.jms.JMSRuntimeException}. * * @param throwingFunction the JmsExceptionThrowingBiConsumer that throws {@link javax.jms.JMSException} * @param <T> type of results. * @return a function that throws {@link javax.jms.JMSRuntimeException} */ static <T> Function<Message, T> wrap(final JmsExceptionThrowingFunction<T> throwingFunction) { return (m) -> { try { return throwingFunction.apply(m); } catch (final JMSException jmsException) { throw new JMSRuntimeException(jmsException.getMessage(), jmsException.getErrorCode(), jmsException.getCause()); } }; }
Example 2
Source File: JmsExceptionThrowingBiConsumer.java From ditto with Eclipse Public License 2.0 | 5 votes |
/** * Wraps a {@link JmsExceptionThrowingBiConsumer} returning a BiConsumer by converting thrown {@link JMSException}s * to {@link JMSRuntimeException}s. * * @param throwingConsumer the JmsExceptionThrowingBiConsumer that throws {@link JMSException} * @return a BiConsumer that throws {@link JMSRuntimeException} */ static <T> BiConsumer<Message, T> wrap(final JmsExceptionThrowingBiConsumer<T> throwingConsumer) { return (m, v) -> { try { throwingConsumer.accept(m, v); } catch (final JMSException jmsException) { throw new JMSRuntimeException(jmsException.getMessage(), jmsException.getErrorCode(), jmsException.getCause()); } }; }
Example 3
Source File: JMSTestBase.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected final void sendMessages(JMSContext context, JMSProducer producer, Queue queue, final int total) { try { for (int j = 0; j < total; j++) { StringBuilder sb = new StringBuilder(); for (int m = 0; m < 200; m++) { sb.append(random.nextLong()); } Message msg = context.createTextMessage(sb.toString()); msg.setIntProperty("counter", j); producer.send(queue, msg); } } catch (JMSException cause) { throw new JMSRuntimeException(cause.getMessage(), cause.getErrorCode(), cause); } }
Example 4
Source File: JMSTestBase.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected final void receiveMessages(JMSConsumer consumer, final int start, final int msgCount, final boolean ack) { try { for (int i = start; i < msgCount; i++) { Message message = consumer.receive(100); Assert.assertNotNull("Expecting a message " + i, message); final int actual = message.getIntProperty("counter"); Assert.assertEquals("expected=" + i + ". Got: property['counter']=" + actual, i, actual); if (ack) message.acknowledge(); } } catch (JMSException cause) { throw new JMSRuntimeException(cause.getMessage(), cause.getErrorCode(), cause); } }
Example 5
Source File: JmsExceptionUtils.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * 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 6
Source File: JMS2.java From tomee with Apache License 2.0 | 5 votes |
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); }