Author: ningjiang
Date: Thu Nov 20 18:44:05 2008
New Revision: 719455
URL: http://svn.apache.org/viewvc?rev=719455&view=rev
Log:
CAMEL-959 added the missing files
Added:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/MyActiveMQConsumer.java
(with props)
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/NonTransactedInOutForJmsWithTxnMgrTest.java
(with props)
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/activemq.xml
(with props)
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/nonTxInOutJmsTest.xml
(with props)
Modified:
activemq/camel/branches/camel-1.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/CamelMessageListener.java
Modified:
activemq/camel/branches/camel-1.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/CamelMessageListener.java
URL:
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/CamelMessageListener.java?rev=719455&r1=719454&r2=719455&view=diff
==============================================================================
---
activemq/camel/branches/camel-1.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/CamelMessageListener.java
(original)
+++
activemq/camel/branches/camel-1.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/CamelMessageListener.java
Thu Nov 20 18:44:05 2008
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,6 +16,9 @@
*/
package org.apache.camel.component.jms;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
@@ -25,10 +27,8 @@
import org.apache.camel.impl.DefaultProducerTemplate;
import org.apache.camel.impl.ProducerTemplateProcessor;
import org.apache.camel.util.ObjectHelper;
-import static org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
+import static org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException;
/**
* A JMS [EMAIL PROTECTED] MessageListener} which converts an incoming JMS
message into a Camel message [EMAIL PROTECTED] Exchange} then
@@ -44,6 +44,13 @@
private final Processor processor;
private JmsBinding binding = new JmsBinding();
private ExchangePattern pattern = ExchangePattern.InOnly;
+
+ public CamelMessageListener(CamelContext camelContext, Processor
processor) {
+ this.camelContext = camelContext;
+ this.processor = processor;
+ ObjectHelper.notNull(processor, "processor");
+ }
+
/**
* Creates a new CamelMessageListener which will invoke a Camel endpoint
@@ -68,13 +75,7 @@
public static CamelMessageListener newInstance(CamelContext camelContext,
ProducerTemplate producerTemplate) {
return new CamelMessageListener(camelContext, new
ProducerTemplateProcessor(producerTemplate));
}
-
- public CamelMessageListener(CamelContext camelContext, Processor
processor) {
- this.camelContext = camelContext;
- this.processor = processor;
- ObjectHelper.notNull(processor, "processor");
- }
-
+
/**
* Processes the incoming JMS message
*/
Added:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/MyActiveMQConsumer.java
URL:
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/MyActiveMQConsumer.java?rev=719455&view=auto
==============================================================================
---
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/MyActiveMQConsumer.java
(added)
+++
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/MyActiveMQConsumer.java
Thu Nov 20 18:44:05 2008
@@ -0,0 +1,89 @@
+/**
+ * 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.tx;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class MyActiveMQConsumer implements Runnable {
+ public static final String ACTIVEMQ_BROKER_URI =
"failover:tcp://localhost:61616";
+ public static final String REQUEST_QUEUE = "request";
+ private static final transient Log LOG =
LogFactory.getLog(MyActiveMQConsumer.class);
+
+ private Connection connection;
+
+ public MyActiveMQConsumer() throws JMSException {
+ ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory(ACTIVEMQ_BROKER_URI);
+ connection = factory.createConnection();
+ }
+
+ public void close() {
+ try {
+ connection.close();
+ } catch (JMSException e) {
+ LOG.info("Get the exception " + e + ", when close the JMS
connection.");
+
+ }
+ }
+
+ public void run() {
+ try {
+ Destination requestDestination = ActiveMQDestination
+ .createDestination(REQUEST_QUEUE,
ActiveMQDestination.QUEUE_TYPE);
+
+ Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumer =
session.createConsumer(requestDestination);
+ connection.start();
+
+ int i = 0;
+
+ while (true) {
+ TextMessage msg = (TextMessage)consumer.receive(1000 * 100);
+ if (msg == null) {
+ LOG.debug("Response timed out.");
+ } else {
+ Destination replyDestination = msg.getJMSReplyTo();
+ String correlationId = msg.getJMSCorrelationID();
+ LOG.debug("replyDestination: " + replyDestination);
+ MessageProducer sender =
session.createProducer(replyDestination);
+ LOG.debug("Request No. " + (++i));
+ LOG.debug("msg: " + msg);
+ TextMessage response = session.createTextMessage();
+ response.setText("I was here: " + msg.getText());
+ response.setJMSCorrelationID(correlationId);
+ LOG.debug("reponse: " + response);
+ sender.send(response);
+ }
+ }
+ } catch (JMSException exception) {
+ LOG.info("Get the exception [" + exception + "], stop receive
message");
+ }
+
+ }
+
+}
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/MyActiveMQConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/MyActiveMQConsumer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/NonTransactedInOutForJmsWithTxnMgrTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/NonTransactedInOutForJmsWithTxnMgrTest.java?rev=719455&view=auto
==============================================================================
---
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/NonTransactedInOutForJmsWithTxnMgrTest.java
(added)
+++
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/NonTransactedInOutForJmsWithTxnMgrTest.java
Thu Nov 20 18:44:05 2008
@@ -0,0 +1,75 @@
+/**
+ * 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.tx;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.spring.SpringRouteBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class NonTransactedInOutForJmsWithTxnMgrTest extends ContextTestSupport
{
+ private static final transient Log LOG =
LogFactory.getLog(NonTransactedInOutForJmsWithTxnMgrTest.class);
+ private MyActiveMQConsumer consumer;
+
+ public void testJmsNonTransactedInOutWithTxnMgr() throws Exception {
+ for (int i = 0; i < 10; i++) {
+ String tmpStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><aft>"
+ i + "</aft>";
+ Object reply = template.requestBody("activemq:mainStage", tmpStr);
+ assertTrue("Received a reply", reply.equals("I was here: " +
tmpStr));
+ LOG.info("received reply: " + reply);
+ }
+ }
+
+ protected ClassPathXmlApplicationContext createApplicationContext() {
+ return new
ClassPathXmlApplicationContext("org/apache/camel/component/jms/tx/nonTxInOutJmsTest.xml");
+ }
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ return
SpringCamelContext.springCamelContext(createApplicationContext());
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new SpringRouteBuilder() {
+ public void configure() throws Exception {
+
from("activemq:queue:mainStage?replyTo=queue:mainStage.reply").to("activemq:queue:request?replyTo=queue:request.reply");
+ }
+ };
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // start the jms consumer here
+ consumer = new MyActiveMQConsumer();
+ Thread thread = new Thread(consumer);
+ thread.start();
+ }
+ @Override
+ protected void tearDown() throws Exception {
+ log.debug("tearDown test: " + getName());
+ Thread.sleep(2000);
+ consumer.close();
+ super.tearDown();
+ }
+}
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/NonTransactedInOutForJmsWithTxnMgrTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/NonTransactedInOutForJmsWithTxnMgrTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/activemq.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/activemq.xml?rev=719455&view=auto
==============================================================================
---
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/activemq.xml
(added)
+++
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/activemq.xml
Thu Nov 20 18:44:05 2008
@@ -0,0 +1,33 @@
+<!--
+ 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.
+-->
+<!-- START SNIPPET: example -->
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:broker="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.1.0.xsd">
+
+ <broker:broker id="broker" useJmx="false" persistent="false"
dataDirectory="target/activemq">
+ <broker:transportConnectors>
+ <broker:transportConnector name="openwire" uri="tcp://localhost:61616"/>
+ </broker:transportConnectors>
+ </broker:broker>
+
+
+</beans>
+<!-- END SNIPPET: example -->
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/activemq.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/activemq.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/activemq.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/nonTxInOutJmsTest.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/nonTxInOutJmsTest.xml?rev=719455&view=auto
==============================================================================
---
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/nonTxInOutJmsTest.xml
(added)
+++
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/nonTxInOutJmsTest.xml
Thu Nov 20 18:44:05 2008
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+
+ <import
resource="classpath:org/apache/camel/component/jms/tx/activemq.xml" />
+
+ <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
+ <property name="configuration" ref="jmsConfig"/>
+ </bean>
+
+ <bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
+ <property name="connectionFactory" ref="jmsConnectionFactory"/>
+ <property name="transactionManager" ref="jmsTransactionManager"/>
+ <property name="transacted" value="true"/>
+ <property name="transactedInOut" value="false" />
+ </bean>
+
+ <bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
+ <property name="brokerURL" value="tcp://localhost:61616"/>
+ </bean>
+
+ <bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
+ <property name="connectionFactory" ref="jmsConnectionFactory"/>
+ </bean>
+</beans>
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/nonTxInOutJmsTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/nonTxInOutJmsTest.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/branches/camel-1.x/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/nonTxInOutJmsTest.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml