View Javadoc

1   /*
2    * $Id: InboundMessageLossTransactionsTestCase.java 22431 2011-07-18 07:40:35Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.jms.reliability;
12  
13  import java.util.concurrent.TimeUnit;
14  
15  import static org.junit.Assert.assertTrue;
16  
17  
18  /**
19   * Verify that no inbound messages are lost when exceptions occur.
20   * The message must either make it all the way to the SEDA queue (in the case of
21   * an asynchronous inbound endpoint), or be restored/rolled back at the source.
22   *
23   * In the case of JMS, this will cause the failed message to be redelivered if
24   * JMSRedelivery is configured.
25   */
26  public class InboundMessageLossTransactionsTestCase extends InboundMessageLossTestCase
27  {
28      @Override
29      protected String getConfigResources()
30      {
31          return "reliability/activemq-config.xml, reliability/inbound-message-loss-transactions.xml";
32      }
33  
34      @Override
35      public void testComponentException() throws Exception
36      {
37          putMessageOnQueue("componentException");
38  
39          // Although a component exception occurs after the SEDA queue, the use of transactions
40          // bypasses the SEDA queue, so message should get redelivered.
41          assertTrue("Message should have been redelivered",
42              messageRedelivered.await(latchTimeout, TimeUnit.MILLISECONDS));
43      }
44  }