Here are the examples of the java api class javax.jms.JMSException taken from open source projects.
1. JmsExceptionSupport#create()
Project: qpid-jms
File: JmsExceptionSupport.java
File: JmsExceptionSupport.java
/** * Creates or passes through a JMSException to be thrown to the client. * * In the event that the exception passed to this method is already a * JMSException it is passed through unmodified, otherwise a new JMSException * is created with the given message and the cause is set to the given * cause Throwable instance. * * @param message * The message value to set when a new JMSException is created. * @param cause * The exception that caused this error state. * * @return a JMSException instance. */ public static JMSException create(String message, Throwable cause) { if (cause instanceof JMSException) { return (JMSException) cause; } if (cause.getCause() instanceof JMSException) { return (JMSException) cause.getCause(); } if (message == null || message.isEmpty()) { message = cause.getMessage(); if (message == null || message.isEmpty()) { message = cause.toString(); } } JMSException exception = new JMSException(message); if (cause instanceof Exception) { exception.setLinkedException((Exception) cause); } exception.initCause(cause); return exception; }
2. BrokerClosesClientConnectionTest#testClientCloseOnBrokerKill()
Project: qpid-java
File: BrokerClosesClientConnectionTest.java
File: BrokerClosesClientConnectionTest.java
public void testClientCloseOnBrokerKill() throws Exception { final Class<? extends Exception> expectedLinkedException = isBroker010() ? ConnectionException.class : AMQDisconnectedException.class; if (!_isExternalBroker) { return; } assertJmsObjectsOpen(); killDefaultBroker(); JMSException exception = _recordingExceptionListener.awaitException(10000); assertConnectionCloseWasReported(exception, expectedLinkedException); assertJmsObjectsClosed(); ensureCanCloseWithoutException(); }
3. BrokerClosesClientConnectionTest#testClientCloseOnNormalBrokerShutdown()
Project: qpid-java
File: BrokerClosesClientConnectionTest.java
File: BrokerClosesClientConnectionTest.java
public void testClientCloseOnNormalBrokerShutdown() throws Exception { final Class<? extends Exception> expectedLinkedException = isBroker010() ? ConnectionException.class : AMQConnectionClosedException.class; assertJmsObjectsOpen(); stopDefaultBroker(); JMSException exception = _recordingExceptionListener.awaitException(10000); assertConnectionCloseWasReported(exception, expectedLinkedException); assertJmsObjectsClosed(); ensureCanCloseWithoutException(); }
4. PooledConnectionFactory#createJmsException()
Project: aries
File: PooledConnectionFactory.java
File: PooledConnectionFactory.java
private JMSException createJmsException(String msg, Exception cause) { JMSException exception = new JMSException(msg); exception.setLinkedException(cause); exception.initCause(cause); return exception; }
5. PooledConnectionFactory#createJmsException()
Project: apache-aries
File: PooledConnectionFactory.java
File: PooledConnectionFactory.java
private JMSException createJmsException(String msg, Exception cause) { JMSException exception = new JMSException(msg); exception.setLinkedException(cause); exception.initCause(cause); return exception; }
6. JMSExceptionHelper#convertFromActiveMQException()
Project: activemq-artemis
File: JMSExceptionHelper.java
File: JMSExceptionHelper.java
public static JMSException convertFromActiveMQException(final ActiveMQException me) { JMSException je; switch(me.getType()) { case CONNECTION_TIMEDOUT: je = new JMSException(me.getMessage()); break; case ILLEGAL_STATE: je = new javax.jms.IllegalStateException(me.getMessage()); break; case INTERNAL_ERROR: je = new JMSException(me.getMessage()); break; case INVALID_FILTER_EXPRESSION: je = new InvalidSelectorException(me.getMessage()); break; case NOT_CONNECTED: je = new JMSException(me.getMessage()); break; case OBJECT_CLOSED: je = new javax.jms.IllegalStateException(me.getMessage()); break; case QUEUE_DOES_NOT_EXIST: je = new InvalidDestinationException(me.getMessage()); break; case QUEUE_EXISTS: je = new InvalidDestinationException(me.getMessage()); break; case SECURITY_EXCEPTION: je = new JMSSecurityException(me.getMessage()); break; case UNSUPPORTED_PACKET: je = new javax.jms.IllegalStateException(me.getMessage()); break; case TRANSACTION_ROLLED_BACK: je = new javax.jms.TransactionRolledBackException(me.getMessage()); break; default: je = new JMSException(me.getMessage()); } je.setStackTrace(me.getStackTrace()); je.initCause(me); return je; }
7. JMSExceptionHelper#convertFromActiveMQException()
Project: activemq-artemis
File: JMSExceptionHelper.java
File: JMSExceptionHelper.java
public static JMSException convertFromActiveMQException(final ActiveMQInterruptedException me) { JMSException je = new javax.jms.IllegalStateException(me.getMessage()); je.setStackTrace(me.getStackTrace()); je.initCause(me); return je; }
8. JMSManagementHelper#convertFromException()
Project: activemq-artemis
File: JMSManagementHelper.java
File: JMSManagementHelper.java
private static JMSException convertFromException(final Exception e) { JMSException jmse = new JMSException(e.getMessage()); jmse.initCause(e); return jmse; }
9. DurableSubscriptionTest#testUnsubscribeWhenUsingSelectorMakesTopicUnreachable()
Project: qpid-java
File: DurableSubscriptionTest.java
File: DurableSubscriptionTest.java
/** * Specifically uses a subscriber with a selector because QPID-4731 found that selectors * can prevent queue removal. */ public void testUnsubscribeWhenUsingSelectorMakesTopicUnreachable() throws Exception { setTestClientSystemProperty("qpid.default_mandatory_topic", "true"); // set up subscription AMQConnection connection = (AMQConnection) getConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = new AMQTopic(connection, MY_TOPIC); MessageProducer producer = session.createProducer(topic); TopicSubscriber subscriber = session.createDurableSubscriber(topic, MY_SUBSCRIPTION, "1 = 1", false); StoringExceptionListener exceptionListener = new StoringExceptionListener(); connection.setExceptionListener(exceptionListener); // send message and verify it was consumed producer.send(session.createTextMessage("message1")); assertNotNull("Message should have been successfully received", subscriber.receive(POSITIVE_RECEIVE_TIMEOUT)); assertEquals(null, exceptionListener.getException()); session.unsubscribe(MY_SUBSCRIPTION); // send another message and verify that the connection exception listener was fired. StoringExceptionListener exceptionListener2 = new StoringExceptionListener(); connection.setExceptionListener(exceptionListener2); producer.send(session.createTextMessage("message that should be unroutable")); ((AMQSession<?, ?>) session).sync(); JMSException exception = exceptionListener2.awaitException(); assertNotNull("Expected exception as message should no longer be routable", exception); Throwable linkedException = exception.getLinkedException(); assertNotNull("The linked exception of " + exception + " should be the 'no route' exception", linkedException); assertEquals(AMQNoRouteException.class, linkedException.getClass()); }
10. UnroutableMessageTestExceptionListener#getReceivedException()
Project: qpid-java
File: UnroutableMessageTestExceptionListener.java
File: UnroutableMessageTestExceptionListener.java
private JMSException getReceivedException() throws Exception { JMSException exception = _exceptions.poll(POSITIVE_TIMEOUT, TimeUnit.SECONDS); assertNotNull("JMSException is expected", exception); return exception; }
11. UnroutableMessageTestExceptionListener#assertReceivedNoConsumersWithReturnedMessage()
Project: qpid-java
File: UnroutableMessageTestExceptionListener.java
File: UnroutableMessageTestExceptionListener.java
public void assertReceivedNoConsumersWithReturnedMessage(Message message) throws Exception { JMSException exception = getReceivedException(); AMQNoConsumersException noConsumersException = (AMQNoConsumersException) exception.getLinkedException(); assertNotNull("AMQNoConsumersException should be linked to JMSException", noConsumersException); Message bounceMessage = (Message) noConsumersException.getUndeliveredMessage(); assertNotNull("Bounced Message is expected", bounceMessage); assertEquals("Unexpected message is bounced", message.getJMSMessageID(), bounceMessage.getJMSMessageID()); }
12. UnroutableMessageTestExceptionListener#assertReceivedNoRoute()
Project: qpid-java
File: UnroutableMessageTestExceptionListener.java
File: UnroutableMessageTestExceptionListener.java
public void assertReceivedNoRoute(String intendedQueueName) throws Exception { JMSException exception = getReceivedException(); assertNoRoute(exception, intendedQueueName); }
13. UnroutableMessageTestExceptionListener#assertReceivedNoRouteWithReturnedMessage()
Project: qpid-java
File: UnroutableMessageTestExceptionListener.java
File: UnroutableMessageTestExceptionListener.java
public void assertReceivedNoRouteWithReturnedMessage(Message message, String intendedQueueName) throws Exception { JMSException exception = getReceivedException(); assertNoRouteExceptionWithReturnedMessage(exception, message, intendedQueueName); }
14. AMQConnectionUnitTest#testExceptionReceived()
Project: qpid-java
File: AMQConnectionUnitTest.java
File: AMQConnectionUnitTest.java
public void testExceptionReceived() { AMQInvalidArgumentException expectedException = new AMQInvalidArgumentException("Test", null); final AtomicReference<JMSException> receivedException = new AtomicReference<JMSException>(); try { MockAMQConnection connection = new MockAMQConnection(_url); connection.setExceptionListener(new ExceptionListener() { @Override public void onException(JMSException jmsException) { receivedException.set(jmsException); } }); connection.exceptionReceived(expectedException); } catch (Exception e) { fail("Failure to test exceptionRecived:" + e.getMessage()); } JMSException exception = receivedException.get(); assertNotNull("Expected JMSException but got null", exception); assertEquals("JMSException error code is incorrect", Integer.toString(expectedException.getErrorCode().getCode()), exception.getErrorCode()); assertNotNull("Expected not null message for JMSException", exception.getMessage()); assertTrue("JMSException error message is incorrect", exception.getMessage().contains(expectedException.getMessage())); assertEquals("JMSException linked exception is incorrect", expectedException, exception.getLinkedException()); }
15. JMSAdapter#exceptionThrown()
Project: flex-blazeds
File: JMSAdapter.java
File: JMSAdapter.java
/** * Implements JMSExceptionListener. * When a JMSConsumer receives a JMS exception from its underlying JMS * connection, it dispatches a JMS exception event to pass the exception * to the JMS adapter. * * @param evt The <code>JMSExceptionEvent</code>. */ public void exceptionThrown(JMSExceptionEvent evt) { JMSConsumer consumer = (JMSConsumer) evt.getSource(); JMSException jmsEx = evt.getJMSException(); // Client is unsubscribed because its corresponding JMS consumer for JMS destination ''{0}'' encountered an error during message delivery: {1} MessageException messageEx = new MessageException(); messageEx.setMessage(JMSConfigConstants.CLIENT_UNSUBSCRIBE_DUE_TO_MESSAGE_DELIVERY_ERROR, new Object[] { consumer.getDestinationJndiName(), jmsEx.getMessage() }); removeConsumer(consumer, true, true, messageEx.createErrorMessage()); }
16. SonicMQVendorAdapter#isRecoverable()
Project: axis1-java
File: SonicMQVendorAdapter.java
File: SonicMQVendorAdapter.java
public boolean isRecoverable(Throwable thrown, int action) { //returns false if (action != ON_EXCEPTION_ACTION && !super.isRecoverable(thrown, action)) return false; if (!(thrown instanceof JMSException)) return true; JMSException jmse = (JMSException) thrown; switch(action) { case CONNECT_ACTION: if (isNetworkFailure(jmse)) return false; break; case SUBSCRIBE_ACTION: if (isQueueMissing(jmse) || isAnotherSubscriberConnected(jmse)) return false; break; case ON_EXCEPTION_ACTION: if (isConnectionDropped(jmse)) return false; break; } return true; }