Example #1
0
  @Override
  public void test() throws JMSException {
    MessageProducer producer = _session.createProducer(_queue);

    Message message = _session.createTextMessage("Message");

    producer.send(message);

    _logger.info("Calling Commit");

    long start = System.nanoTime();
    try {
      _session.commit();
      fail("Commit occured even though syncWait timeout is shorter than delay in commit");
    } catch (JMSException e) {
      assertTrue(
          "Wrong exception type received.", e.getLinkedException() instanceof AMQTimeoutException);
      assertTrue(
          "Wrong message received on exception.", e.getMessage().startsWith("Failed to commit"));
      // As we are using Nano time ensure to multiply up the millis.
      assertTrue(
          "Timeout was more than 30s default",
          (System.nanoTime() - start) < (1000000L * 1000 * 30));
    }
  }
Example #2
0
 public Throwable getCause(Throwable t) {
   JMSException e = (JMSException) t;
   Throwable cause = e.getLinkedException();
   if (cause == null) {
     cause = e.getCause();
   }
   return cause;
 }
Example #3
0
 /**
  * Build a descriptive exception message for the given JMSException, incorporating a linked
  * exception's message if appropriate.
  *
  * @param ex the JMSException to build a message for
  * @return the descriptive message String
  * @see javax.jms.JMSException#getLinkedException()
  */
 public static String buildExceptionMessage(JMSException ex) {
   String message = ex.getMessage();
   Exception linkedEx = ex.getLinkedException();
   if (linkedEx != null) {
     if (message == null) {
       message = linkedEx.toString();
     } else {
       String linkedMessage = linkedEx.getMessage();
       if (linkedMessage != null && !message.contains(linkedMessage)) {
         message = message + "; nested exception is " + linkedEx;
       }
     }
   }
   return message;
 }