activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r520213 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-jms/src/main/java/org/apache/camel/jms/ camel-jms/src/test/ide-resources/ camel-jms/src/test/java/org/apache/camel/jms/
Date Tue, 20 Mar 2007 02:00:06 GMT
Author: jstrachan
Date: Mon Mar 19 19:00:05 2007
New Revision: 520213

URL: http://svn.apache.org/viewvc?view=rev&rev=520213
Log:
test case working (though it doesn't actually test the message is received yet :)

Added:
    activemq/camel/trunk/camel-jms/src/test/ide-resources/
    activemq/camel/trunk/camel-jms/src/test/ide-resources/log4j.properties
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java
    activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/jms/JmsRouteTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java?view=diff&rev=520213&r1=520212&r2=520213
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContainer.java Mon
Mar 19 19:00:05 2007
@@ -75,6 +75,15 @@
     }
 
 
+    /**
+     * Resolves the given URI to an endpoint
+     */
+    public Endpoint<E> endpoint(String uri) {
+         EndpointResolver<E> er = getEndpointResolver();
+         return er.resolveEndpoint(this, uri);
+    }
+
+
     // Properties
     //-----------------------------------------------------------------------
     public EndpointResolver<E> getEndpointResolver() {

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java?view=diff&rev=520213&r1=520212&r2=520213
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java (original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsComponent.java Mon
Mar 19 19:00:05 2007
@@ -113,7 +113,7 @@
         // messageConverter
         // durableSubscriberName 
 
-        return new JmsEndpoint(uri, container, template, listenerContainer);
+        return new JmsEndpoint(uri, container, subject, template, listenerContainer);
     }
 
     public JmsTemplate getTemplate() {

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java?view=diff&rev=520213&r1=520212&r2=520213
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java (original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/jms/JmsEndpoint.java Mon
Mar 19 19:00:05 2007
@@ -20,6 +20,8 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.jms.core.JmsOperations;
 import org.springframework.jms.core.MessageCreator;
 import org.springframework.jms.listener.AbstractMessageListenerContainer;
@@ -33,18 +35,24 @@
  * @version $Revision$
  */
 public class JmsEndpoint extends DefaultEndpoint<JmsExchange> implements MessageListener
{
+    private static final Log log = LogFactory.getLog(JmsEndpoint.class);
 
     private JmsOperations template;
     private AbstractMessageListenerContainer listenerContainer;
+    private String destination;
 
-    public JmsEndpoint(String endpointUri, CamelContainer container, JmsOperations template,
AbstractMessageListenerContainer listenerContainer) {
+    public JmsEndpoint(String endpointUri, CamelContainer container, String destination,
JmsOperations template, AbstractMessageListenerContainer listenerContainer) {
         super(endpointUri, container);
+        this.destination = destination;
         this.template = template;
         this.listenerContainer = listenerContainer;
         this.listenerContainer.setMessageListener(this);
     }
 
     public void onMessage(Message message) {
+        if (log.isDebugEnabled()) {
+            log.debug(JmsEndpoint.this + " receiving JMS message: " + message);
+        }
         JmsExchange exchange = createExchange(message);
         getInboundProcessor().onExchange(exchange);
     }
@@ -57,9 +65,13 @@
     }
 
     public void send(final JmsExchange exchange) {
-        template.send(new MessageCreator() {
+        template.send(destination, new MessageCreator() {
             public Message createMessage(Session session) throws JMSException {
-                return exchange.createMessage(session);
+                Message message = exchange.createMessage(session);
+                if (log.isDebugEnabled()) {
+                    log.debug(JmsEndpoint.this + " sending JMS message: " + message);
+                }
+                return message;
             }
         });
     }

Added: activemq/camel/trunk/camel-jms/src/test/ide-resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/test/ide-resources/log4j.properties?view=auto&rev=520213
==============================================================================
--- activemq/camel/trunk/camel-jms/src/test/ide-resources/log4j.properties (added)
+++ activemq/camel/trunk/camel-jms/src/test/ide-resources/log4j.properties Mon Mar 19 19:00:05
2007
@@ -0,0 +1,30 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.activemq=DEBUG
+log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n

Modified: activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/jms/JmsRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/jms/JmsRouteTest.java?view=diff&rev=520213&r1=520212&r2=520213
==============================================================================
--- activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/jms/JmsRouteTest.java (original)
+++ activemq/camel/trunk/camel-jms/src/test/java/org/apache/camel/jms/JmsRouteTest.java Mon
Mar 19 19:00:05 2007
@@ -18,13 +18,15 @@
 package org.apache.camel.jms;
 
 import junit.framework.TestCase;
+import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.camel.CamelContainer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import static org.apache.camel.jms.JmsComponent.jmsComponent;
+import org.springframework.jms.core.JmsTemplate;
 
-import static org.apache.camel.jms.JmsComponent.*;
-import org.apache.activemq.ActiveMQConnectionFactory;
-
-import javax.jms.ConnectionFactory;
+import javax.jms.Session;
 
 /**
  * @version $Revision$
@@ -36,14 +38,35 @@
         System.out.println("Created container: " + container);
         
         // lets configure some componnets
-        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
-        container.addComponent("activemq", jmsComponent(connectionFactory));
+        JmsTemplate template = new JmsTemplate(new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"));
+        template.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
+        template.setSessionTransacted(false);
+        
+        container.addComponent("activemq", jmsComponent(template));
 
         // lets add some routes
         container.routes(new RouteBuilder() {
             public void configure() {
-                from("jms:activemq:FOO.BAR").to("jms:activemq:FOO.BAR");
+                from("jms:activemq:test.a").to("jms:activemq:test.b");
+                from("jms:activemq:test.b").process(new Processor<JmsExchange>() {
+                    public void onExchange(JmsExchange exchange) {
+                        System.out.println("Received exchange: " + exchange.getRequest());
+                    }
+                });
             }
         });
+
+        // now lets fire in a message
+        Endpoint<JmsExchange> endpoint = container.endpoint("jms:activemq:test.a");
+        JmsExchange exchange2 = endpoint.createExchange();
+        //exchange2.setInBody("Hello there!")
+        exchange2.setHeader("cheese", 123);
+        endpoint.send(exchange2);
+
+        // now lets sleep for a while
+        Thread.sleep(3000);
+
+        // TODO
+        //container.stop();
     }
 }



Mime
View raw message