Author: davsclaus Date: Wed Aug 29 12:49:40 2012 New Revision: 1378526 URL: http://svn.apache.org/viewvc?rev=1378526&view=rev Log: Added test based on user forum issue
Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.java (with props) camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.xml - copied, changed from r1378512, camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/TransactionErrorHandlerRedeliveryDelayTest-context.xml Added: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.java?rev=1378526&view=auto ============================================================================== --- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.java (added) +++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.java Wed Aug 29 12:49:40 2012 @@ -0,0 +1,59 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.jms.issues; + +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelSpringTestSupport; +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * + */ +public class JmsTXForceShutdownIssueTest extends CamelSpringTestSupport { + + @Override + protected AbstractApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.xml"); + } + + @Override + protected int getShutdownTimeout() { + // force a bit faster forced shutdown + return 5; + } + + @Test + @Ignore("This is a manual test, start Apache ActiveMQ broker manually first, using bin/activemq console") + // and make sure to setup tcp transport connector on the remote AMQ broker in the conf/activemq.xml file + // <transportConnectors> + // <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/> + // </transportConnectors> + // the ActiveMQ web console can be used to browse the queue: http://0.0.0.0:8161/admin/ + public void testTXForceShutdown() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:inflight"); + mock.expectedMessageCount(1); + + template.sendBody("activemq:queue:inbox", "Hello World"); + + assertMockEndpointsSatisfied(); + + // will complete the test and force a shutdown ... + } +} Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Copied: camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.xml (from r1378512, camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/TransactionErrorHandlerRedeliveryDelayTest-context.xml) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.xml?p2=camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.xml&p1=camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/TransactionErrorHandlerRedeliveryDelayTest-context.xml&r1=1378512&r2=1378526&rev=1378526&view=diff ============================================================================== --- camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/TransactionErrorHandlerRedeliveryDelayTest-context.xml (original) +++ camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/issues/JmsTXForceShutdownIssueTest.xml Wed Aug 29 12:49:40 2012 @@ -22,51 +22,46 @@ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> - <jmxAgent id="agent" disabled="true"/> - <route errorHandlerRef="myTransactionErrorHandler"> - <from uri="activemq:queue:in"/> - <transacted ref="required"/> - <process ref="myFailureProcessor"/> - <to uri="mock:result"/> - </route> - </camelContext> - - <bean id="myFailureProcessor" class="org.apache.camel.component.jms.issues.TransactionErrorHandlerRedeliveryDelayTest$MyFailureProcessor"/> - <bean id="myTransactionErrorHandler" class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder"> - <property name="transactionTemplate" ref="PROPAGATION_REQUIRED"/> - </bean> - - <bean id="required" class="org.apache.camel.spring.spi.SpringTransactionPolicy"> - <property name="transactionTemplate" ref="PROPAGATION_REQUIRED"/> - </bean> + <!-- try to redeliver forever --> + <errorHandler id="eh" type="TransactionErrorHandler"> + <redeliveryPolicy maximumRedeliveries="-1" redeliveryDelay="1000" + retryAttemptedLogLevel="INFO" retriesExhaustedLogLevel="WARN" + logStackTrace="false" logRetryAttempted="true" logExhausted="true"/> + </errorHandler> + + <route errorHandlerRef="eh"> + <from uri="activemq:queue:inbox"/> + <transacted/> + <to uri="mock:inflight"/> + <throwException ref="myException"/> + <to uri="log:outbox"/> + </route> + </camelContext> - <bean id="PROPAGATION_REQUIRED" class="org.springframework.transaction.support.TransactionTemplate"> - <property name="transactionManager" ref="jmsTransactionManager"/> - </bean> + <bean id="myException" class="java.lang.IllegalArgumentException"> + <constructor-arg index="0" value="Forced"/> + </bean> <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager"> <property name="connectionFactory" ref="poolConnectionFactory"/> </bean> - <bean id="poolConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"> + <bean id="poolConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" + init-method="start" destroy-method="stop"> <property name="maxConnections" value="8"/> <property name="connectionFactory" ref="jmsConnectionFactory"/> </bean> <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> - <property name="brokerURL" value="vm://localhost?broker.persistent=false&broker.useJmx=false"/> - </bean> - - <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration"> - <property name="connectionFactory" ref="poolConnectionFactory"/> - <property name="transactionManager" ref="jmsTransactionManager"/> - <property name="transacted" value="true"/> - <property name="concurrentConsumers" value="1"/> + <property name="brokerURL" value="tcp://localhost:61616"/> </bean> <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> - <property name="configuration" ref="jmsConfig"/> + <property name="connectionFactory" ref="poolConnectionFactory"/> + <property name="transactionManager" ref="jmsTransactionManager"/> + <property name="transacted" value="true"/> + <property name="concurrentConsumers" value="1"/> </bean> </beans>