Here are some test cases. @Test //The timeout is set in the resetTask() method which is called at the completion of the exchange (SessionBatchTransactionSynchronization.java). //If I'm understanding it well, the timeout seems to be reset at each exchange completion. //That is not really the definition of a timeout. //So, if the processing of the first exchange takes more time than the timeout, the test is still successful (because the timeout was never triggered) public void timeOutNotWorkingWithFirstExchange () throws InterruptedException { // Setup expectations MockEndpoint mock = getMockEndpoint("mock:output"); mock.expectedMessageCount(2); mock.expectedBodiesReceived("Test timeout");
// Send test exchange to second broker template.sendBody("sjms:JUNIT_1", "Test timeout"); // Verify asserts mock.assertIsSatisfied(5000); } @Test public void batchTransactionWithAggregateTest () throws InterruptedException { // Setup expectations // Send test exchange to second broker template.sendBody("sjms:JUNIT_2", "My first body"); template.sendBody("sjms:JUNIT_2", "My second body"); // Message are committed in the queue. The message should be roll backed because the aggregated exchange failed } @Test public void timeOutCommitEvenIfExchangeStillInflight () throws InterruptedException { // Setup expectations // Send test exchange to second broker template.sendBody("asjms:JUNIT_3", "Test"); template.sendBody("asjms:JUNIT_3", "Message Inflight"); //Transaction is committed (due to timeout) even if the exchange is still inflight } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("sjms:JUNIT_1?transacted=true&transactionBatchCount=2&transactionBatchTimeout=1000").delay(4000).to("mock:output"); from("asjms:JUNIT_3?transacted=true&transactionBatchCount=2&transactionBatchTimeout=2000") .choice() .when(body().endsWith("Inflight")) .delay(5000) .throwException(new Exception("Exception on inflight exchange")) .end() // <<< .end() .log("Finished"); from("sjms:JUNIT_2?transacted=true&transactionBatchCount=2&transactionBatchTimeout=1000") .aggregate(constant("all"), new SimpleAggregationStrategy()) .completionSize(2) .delay(8000) .log("Test") .throwException(new Exception("Aggregate message failed")) .end().log("TestAFter"); } }; } -- View this message in context: http://camel.465427.n5.nabble.com/SJMS-implementation-Batch-Consumer-tp5741291p5741333.html Sent from the Camel Development mailing list archive at Nabble.com.