camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From javaxmlsoapdev <javaxmlsoap...@yahoo.com>
Subject Re: Transacted test case with ActiveMQ not working
Date Thu, 26 Apr 2012 13:56:20 GMT
Thanks all for taking time in responding. However it still doesn't work for
me. May some stupid mistake? Any other ideas?

here is how my route definition looks like in Java DSL

@Component
public class CustomRouter extends SpringRouteBuilder{
	@Autowired
	private CustomQProcessor customQProcessor;
	
    public void configure() {
    	String sourceQName ="";
    	try {
			sourceQName =
getContext().resolvePropertyPlaceholders("{{sourceQ.name}}");
		} catch (Exception e) {
			
			e.printStackTrace();
		}
    	 	from(sourceQName)
	    	.transacted()
	    	.process(customQProcessor)
	    	.recipientList(header("recepientList")).parallelProcessing();
    	}
}

config is as below.

<broker:broker id="broker" useJmx="false" persistent="true"
brokerName="localhost">
		<broker:transportConnectors>
			<broker:transportConnector uri="vm://localhost:61616"/>
		</broker:transportConnectors>
	</broker:broker>
	
	<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
    	<property name="connectionFactory" ref="pooledConnectionFactory"/>
	</bean>
	<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="broker">
		<property name="brokerURL" value="vm://localhost:61616" />
	</bean>
	<bean id="pooledConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
		<property name="maxConnections" value="5" />
		<property name="connectionFactory" ref="jmsConnectionFactory" />
	</bean>

	<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
		<property name="connectionFactory" ref="pooledConnectionFactory" />
		<property name="transacted" value="true" />
	</bean>
	
	<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
		<property name="brokerURL" value="vm://localhost:61616"/>
	</bean>


Following is a test case which fails

Endpoint sourceQendPoint = sourceQueue.getDefaultEndpoint();
		RouteBuilder rb = new RouteBuilder(){
			public void configure() throws Exception{
				interceptSendToEndpoint("activemq:queue:destiQueue1")
					.throwException(new JMSException("Cannot publish to destiQueue1"));
			}
		};
		RouteDefinition eventRoute = camelContext.getRouteDefinition("route1");
		eventRoute.adviceWith((ModelCamelContext)camelContext, rb);
		
		template.sendBody(sourceQendPoint,"Test message");
		Thread.sleep(3000);
		Object body = consumer.receiveBodyNoWait("activemq:queue:ActiveMQ.DLQ");
		assertNotNull("should not lose message",body);

--
View this message in context: http://camel.465427.n5.nabble.com/Transacted-test-case-with-ActiveMQ-not-working-tp5666012p5667684.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message