You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2008/12/08 16:40:16 UTC

svn commit: r724380 - in /activemq/camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/ test/java/org/apache/camel/component/jms/config/ test/resources/org/apache/camel/component/jms/config/

Author: jstrachan
Date: Mon Dec  8 07:40:15 2008
New Revision: 724380

URL: http://svn.apache.org/viewvc?rev=724380&view=rev
Log:
added a fix for CAMEL-1147 along with a test; this also improves CAMEL-505 allowing a JmsEndpoint to be created and configured directly

Added:
    activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/config/
    activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest.java   (with props)
    activemq/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/config/
    activemq/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest-context.xml   (with props)
Modified:
    activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
    activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
    activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java

Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java?rev=724380&r1=724379&r2=724380&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java Mon Dec  8 07:40:15 2008
@@ -19,18 +19,26 @@
 import javax.jms.Message;
 import javax.jms.TemporaryQueue;
 import javax.jms.TemporaryTopic;
+import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
+import javax.jms.Destination;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.HeaderFilterStrategyAware;
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.Processor;
+import org.apache.camel.Component;
 import org.apache.camel.component.jms.requestor.Requestor;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.springframework.jms.core.JmsOperations;
 import org.springframework.jms.core.JmsTemplate;
 import org.springframework.jms.listener.AbstractMessageListenerContainer;
+import org.springframework.jms.support.destination.DestinationResolver;
+import org.springframework.jms.support.converter.MessageConverter;
+import org.springframework.core.task.TaskExecutor;
+import org.springframework.transaction.PlatformTransactionManager;
 
 /**
  * A <a href="http://activemq.apache.org/jms.html">JMS Endpoint</a>
@@ -40,35 +48,40 @@
 public class JmsEndpoint extends DefaultEndpoint {
     private final boolean pubSubDomain;
     private JmsBinding binding;
-    private String destination;
+    private String destinationName;
+    private Destination destination;
     private String selector;
     private JmsConfiguration configuration;
     private Requestor requestor;
 
-    public JmsEndpoint(String uri, JmsComponent component, String destination, boolean pubSubDomain, JmsConfiguration configuration) {
+    public JmsEndpoint(String uri, JmsComponent component, String destinationName, boolean pubSubDomain, JmsConfiguration configuration) {
         super(uri, component);
         this.configuration = configuration;
-        this.destination = destination;
+        this.destinationName = destinationName;
         this.pubSubDomain = pubSubDomain;
     }
 
-    public JmsEndpoint(String endpointUri, JmsBinding binding, JmsConfiguration configuration, String destination, boolean pubSubDomain) {
+    public JmsEndpoint(String endpointUri, JmsBinding binding, JmsConfiguration configuration, String destinationName, boolean pubSubDomain) {
         super(endpointUri);
         this.binding = binding;
         this.configuration = configuration;
-        this.destination = destination;
+        this.destinationName = destinationName;
         this.pubSubDomain = pubSubDomain;
     }
 
-    public JmsEndpoint(String endpointUri, String destination, boolean pubSubDomain) {
-        this(endpointUri, new JmsBinding(), new JmsConfiguration(), destination, pubSubDomain);
+    public JmsEndpoint(String endpointUri, String destinationName, boolean pubSubDomain) {
+        this(endpointUri, new JmsBinding(), new JmsConfiguration(), destinationName, pubSubDomain);
     }
 
     /**
      * Creates a pub-sub endpoint with the given destination
      */
-    public JmsEndpoint(String endpointUri, String destination) {
-        this(endpointUri, destination, true);
+    public JmsEndpoint(String endpointUri, String destinationName) {
+        this(endpointUri, destinationName, true);
+    }
+
+    public JmsEndpoint() {
+        this(null, null);
     }
 
     public JmsProducer createProducer() throws Exception {
@@ -83,12 +96,29 @@
         if (template instanceof JmsTemplate) {
             JmsTemplate jmsTemplate = (JmsTemplate) template;
             jmsTemplate.setPubSubDomain(pubSubDomain);
-            jmsTemplate.setDefaultDestinationName(destination);
+            if (destinationName != null) {
+                jmsTemplate.setDefaultDestinationName(destinationName);
+            }
+            else if (destination != null) {
+                jmsTemplate.setDefaultDestination(destination);
+            }
+            /*
+            else {
+                DestinationResolver resolver = getDestinationResolver();
+                if (resolver != null) {
+                    jmsTemplate.setDestinationResolver(resolver);
+                }
+                else {
+                    throw new IllegalArgumentException("Neither destination, destinationName or destinationResolver are specified on this endpoint!");
+                }
+            }
+            */
         }
         answer.setInOnlyTemplate(template);
         return answer;
     }
 
+
     public JmsConsumer createConsumer(Processor processor) throws Exception {
         AbstractMessageListenerContainer listenerContainer = configuration.createMessageListenerContainer(this);
         return createConsumer(processor, listenerContainer);
@@ -103,7 +133,18 @@
      * @throws Exception if the consumer cannot be created
      */
     public JmsConsumer createConsumer(Processor processor, AbstractMessageListenerContainer listenerContainer) throws Exception {
-        listenerContainer.setDestinationName(destination);
+        if (destinationName != null) {
+            listenerContainer.setDestinationName(destinationName);
+        } else if (destination != null) {
+            listenerContainer.setDestination(destination);
+        } else {
+            DestinationResolver resolver = getDestinationResolver();
+            if (resolver != null) {
+                listenerContainer.setDestinationResolver(resolver);
+            } else {
+                throw new IllegalArgumentException("Neither destination, destinationName or destinationResolver are specified on this endpoint!");
+            }
+        }
         listenerContainer.setPubSubDomain(pubSubDomain);
         return new JmsConsumer(this, processor, listenerContainer);
     }
@@ -127,14 +168,14 @@
      * Factory method for creating a new template for InOnly message exchanges
      */
     public JmsOperations createInOnlyTemplate() {
-        return configuration.createInOnlyTemplate(this, pubSubDomain, destination);
+        return configuration.createInOnlyTemplate(this, pubSubDomain, destinationName);
     }
 
     /**
      * Factory method for creating a new template for InOut message exchanges
      */
     public JmsOperations createInOutTemplate() {
-        return configuration.createInOutTemplate(this, pubSubDomain, destination, configuration.getRequestTimeout());
+        return configuration.createInOutTemplate(this, pubSubDomain, destinationName, configuration.getRequestTimeout());
     }
 
     // Properties
@@ -156,14 +197,33 @@
         this.binding = binding;
     }
 
-    public String getDestination() {
+    public String getDestinationName() {
+        return destinationName;
+    }
+
+    public void setDestinationName(String destinationName) {
+        this.destinationName = destinationName;
+    }
+
+    public Destination getDestination() {
         return destination;
     }
 
+    /**
+     * Allows a specific JMS Destination object to be used as the destination
+     */
+    public void setDestination(Destination destination) {
+        this.destination = destination;
+    }
+
     public JmsConfiguration getConfiguration() {
         return configuration;
     }
 
+    public void setConfiguration(JmsConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
     public String getSelector() {
         return selector;
     }
@@ -226,6 +286,7 @@
         return metadata;
     }
 
+
     /**
      * Returns the {@link JmsOperations} used for metadata operations such as creating temporary destinations
      */
@@ -254,4 +315,434 @@
         }
     }
 
+    // Delegated properties from the configuration
+    //-------------------------------------------------------------------------
+    public int getAcknowledgementMode() {
+        return getConfiguration().getAcknowledgementMode();
+    }
+
+    public String getAcknowledgementModeName() {
+        return getConfiguration().getAcknowledgementModeName();
+    }
+
+    public int getCacheLevel() {
+        return getConfiguration().getCacheLevel();
+    }
+
+    public String getCacheLevelName() {
+        return getConfiguration().getCacheLevelName();
+    }
+
+    public String getClientId() {
+        return getConfiguration().getClientId();
+    }
+
+    public int getConcurrentConsumers() {
+        return getConfiguration().getConcurrentConsumers();
+    }
+
+    public ConnectionFactory getConnectionFactory() {
+        return getConfiguration().getConnectionFactory();
+    }
+
+    public ConsumerType getConsumerType() {
+        return getConfiguration().getConsumerType();
+    }
+
+    public DestinationResolver getDestinationResolver() {
+        return getConfiguration().getDestinationResolver();
+    }
+
+    public String getDurableSubscriptionName() {
+        return getConfiguration().getDurableSubscriptionName();
+    }
+
+    public ExceptionListener getExceptionListener() {
+        return getConfiguration().getExceptionListener();
+    }
+
+    public int getIdleTaskExecutionLimit() {
+        return getConfiguration().getIdleTaskExecutionLimit();
+    }
+
+    public JmsOperations getJmsOperations() {
+        return getConfiguration().getJmsOperations();
+    }
+
+    public ConnectionFactory getListenerConnectionFactory() {
+        return getConfiguration().getListenerConnectionFactory();
+    }
+
+    public int getMaxConcurrentConsumers() {
+        return getConfiguration().getMaxConcurrentConsumers();
+    }
+
+    public int getMaxMessagesPerTask() {
+        return getConfiguration().getMaxMessagesPerTask();
+    }
+
+    public MessageConverter getMessageConverter() {
+        return getConfiguration().getMessageConverter();
+    }
+
+    public JmsOperations getMetadataJmsOperations(JmsEndpoint endpoint) {
+        return getConfiguration().getMetadataJmsOperations(endpoint);
+    }
+
+    public int getPriority() {
+        return getConfiguration().getPriority();
+    }
+
+    public long getReceiveTimeout() {
+        return getConfiguration().getReceiveTimeout();
+    }
+
+    public long getRecoveryInterval() {
+        return getConfiguration().getRecoveryInterval();
+    }
+
+    public String getReplyTo() {
+        return getConfiguration().getReplyTo();
+    }
+
+    public String getReplyToDestinationSelectorName() {
+        return getConfiguration().getReplyToDestinationSelectorName();
+    }
+
+    public String getReplyToTempDestinationAffinity() {
+        return getConfiguration().getReplyToTempDestinationAffinity();
+    }
+
+    public long getRequestMapPurgePollTimeMillis() {
+        return getConfiguration().getRequestMapPurgePollTimeMillis();
+    }
+
+    public long getRequestTimeout() {
+        return getConfiguration().getRequestTimeout();
+    }
+
+    public TaskExecutor getTaskExecutor() {
+        return getConfiguration().getTaskExecutor();
+    }
+
+    public ConnectionFactory getTemplateConnectionFactory() {
+        return getConfiguration().getTemplateConnectionFactory();
+    }
+
+    public long getTimeToLive() {
+        return getConfiguration().getTimeToLive();
+    }
+
+    public PlatformTransactionManager getTransactionManager() {
+        return getConfiguration().getTransactionManager();
+    }
+
+    public String getTransactionName() {
+        return getConfiguration().getTransactionName();
+    }
+
+    public int getTransactionTimeout() {
+        return getConfiguration().getTransactionTimeout();
+    }
+
+    public boolean isAcceptMessagesWhileStopping() {
+        return getConfiguration().isAcceptMessagesWhileStopping();
+    }
+
+    public boolean isAlwaysCopyMessage() {
+        return getConfiguration().isAlwaysCopyMessage();
+    }
+
+    public boolean isAutoStartup() {
+        return getConfiguration().isAutoStartup();
+    }
+
+    public boolean isDeliveryPersistent() {
+        return getConfiguration().isDeliveryPersistent();
+    }
+
+    public boolean isDisableReplyTo() {
+        return getConfiguration().isDisableReplyTo();
+    }
+
+    public boolean isEagerLoadingOfProperties() {
+        return getConfiguration().isEagerLoadingOfProperties();
+    }
+
+    public boolean isExplicitQosEnabled() {
+        return getConfiguration().isExplicitQosEnabled();
+    }
+
+    public boolean isExposeListenerSession() {
+        return getConfiguration().isExposeListenerSession();
+    }
+
+    public boolean isMessageIdEnabled() {
+        return getConfiguration().isMessageIdEnabled();
+    }
+
+    public boolean isMessageTimestampEnabled() {
+        return getConfiguration().isMessageTimestampEnabled();
+    }
+
+    public boolean isPreserveMessageQos() {
+        return getConfiguration().isPreserveMessageQos();
+    }
+
+    public boolean isPubSubNoLocal() {
+        return getConfiguration().isPubSubNoLocal();
+    }
+
+    public boolean isReplyToDeliveryPersistent() {
+        return getConfiguration().isReplyToDeliveryPersistent();
+    }
+
+    public boolean isSubscriptionDurable() {
+        return getConfiguration().isSubscriptionDurable();
+    }
+
+    public boolean isTransacted() {
+        return getConfiguration().isTransacted();
+    }
+
+    public boolean isTransactedInOut() {
+        return getConfiguration().isTransactedInOut();
+    }
+
+    public boolean isUseMessageIDAsCorrelationID() {
+        return getConfiguration().isUseMessageIDAsCorrelationID();
+    }
+
+    public boolean isUseVersion102() {
+        return getConfiguration().isUseVersion102();
+    }
+
+    public void setAcceptMessagesWhileStopping(boolean acceptMessagesWhileStopping) {
+        getConfiguration().setAcceptMessagesWhileStopping(acceptMessagesWhileStopping);
+    }
+
+    public void setAcknowledgementMode(int consumerAcknowledgementMode) {
+        getConfiguration().setAcknowledgementMode(consumerAcknowledgementMode);
+    }
+
+    public void setAcknowledgementModeName(String consumerAcknowledgementMode) {
+        getConfiguration().setAcknowledgementModeName(consumerAcknowledgementMode);
+    }
+
+    public void setAlwaysCopyMessage(boolean alwaysCopyMessage) {
+        getConfiguration().setAlwaysCopyMessage(alwaysCopyMessage);
+    }
+
+    public void setAutoStartup(boolean autoStartup) {
+        getConfiguration().setAutoStartup(autoStartup);
+    }
+
+    public void setCacheLevel(int cacheLevel) {
+        getConfiguration().setCacheLevel(cacheLevel);
+    }
+
+    public void setCacheLevelName(String cacheName) {
+        getConfiguration().setCacheLevelName(cacheName);
+    }
+
+    public void setClientId(String consumerClientId) {
+        getConfiguration().setClientId(consumerClientId);
+    }
+
+    public void setConcurrentConsumers(int concurrentConsumers) {
+        getConfiguration().setConcurrentConsumers(concurrentConsumers);
+    }
+
+    public void setConnectionFactory(ConnectionFactory connectionFactory) {
+        getConfiguration().setConnectionFactory(connectionFactory);
+    }
+
+    public void setConsumerType(ConsumerType consumerType) {
+        getConfiguration().setConsumerType(consumerType);
+    }
+
+    public void setDeliveryPersistent(boolean deliveryPersistent) {
+        getConfiguration().setDeliveryPersistent(deliveryPersistent);
+    }
+
+    public void setDestinationResolver(DestinationResolver destinationResolver) {
+        getConfiguration().setDestinationResolver(destinationResolver);
+    }
+
+
+    public void setDisableReplyTo(boolean disableReplyTo) {
+        getConfiguration().setDisableReplyTo(disableReplyTo);
+    }
+
+    public void setDurableSubscriptionName(String durableSubscriptionName) {
+        getConfiguration().setDurableSubscriptionName(durableSubscriptionName);
+    }
+
+    public void setEagerLoadingOfProperties(boolean eagerLoadingOfProperties) {
+        getConfiguration().setEagerLoadingOfProperties(eagerLoadingOfProperties);
+    }
+
+    public void setExceptionListener(ExceptionListener exceptionListener) {
+        getConfiguration().setExceptionListener(exceptionListener);
+    }
+
+    public void setExplicitQosEnabled(boolean explicitQosEnabled) {
+        getConfiguration().setExplicitQosEnabled(explicitQosEnabled);
+    }
+
+    public void setExposeListenerSession(boolean exposeListenerSession) {
+        getConfiguration().setExposeListenerSession(exposeListenerSession);
+    }
+
+    public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit) {
+        getConfiguration().setIdleTaskExecutionLimit(idleTaskExecutionLimit);
+    }
+
+    public void setJmsOperations(JmsOperations jmsOperations) {
+        getConfiguration().setJmsOperations(jmsOperations);
+    }
+
+    public void setListenerConnectionFactory(ConnectionFactory listenerConnectionFactory) {
+        getConfiguration().setListenerConnectionFactory(listenerConnectionFactory);
+    }
+
+    public void setMaxConcurrentConsumers(int maxConcurrentConsumers) {
+        getConfiguration().setMaxConcurrentConsumers(maxConcurrentConsumers);
+    }
+
+    public void setMaxMessagesPerTask(int maxMessagesPerTask) {
+        getConfiguration().setMaxMessagesPerTask(maxMessagesPerTask);
+    }
+
+    public void setMessageConverter(MessageConverter messageConverter) {
+        getConfiguration().setMessageConverter(messageConverter);
+    }
+
+    public void setMessageIdEnabled(boolean messageIdEnabled) {
+        getConfiguration().setMessageIdEnabled(messageIdEnabled);
+    }
+
+    public void setMessageTimestampEnabled(boolean messageTimestampEnabled) {
+        getConfiguration().setMessageTimestampEnabled(messageTimestampEnabled);
+    }
+
+    public void setMetadataJmsOperations(JmsOperations metadataJmsOperations) {
+        getConfiguration().setMetadataJmsOperations(metadataJmsOperations);
+    }
+
+    public void setPreserveMessageQos(boolean preserveMessageQos) {
+        getConfiguration().setPreserveMessageQos(preserveMessageQos);
+    }
+
+    public void setPriority(int priority) {
+        getConfiguration().setPriority(priority);
+    }
+
+    public void setProviderMetadata(JmsProviderMetadata providerMetadata) {
+        getConfiguration().setProviderMetadata(providerMetadata);
+    }
+
+    public void setPubSubNoLocal(boolean pubSubNoLocal) {
+        getConfiguration().setPubSubNoLocal(pubSubNoLocal);
+    }
+
+    public void setReceiveTimeout(long receiveTimeout) {
+        getConfiguration().setReceiveTimeout(receiveTimeout);
+    }
+
+    public void setRecoveryInterval(long recoveryInterval) {
+        getConfiguration().setRecoveryInterval(recoveryInterval);
+    }
+
+    public void setReplyTo(String replyToDestination) {
+        getConfiguration().setReplyTo(replyToDestination);
+    }
+
+    public void setReplyToDeliveryPersistent(boolean replyToDeliveryPersistent) {
+        getConfiguration().setReplyToDeliveryPersistent(replyToDeliveryPersistent);
+    }
+
+    public void setReplyToDestinationSelectorName(String replyToDestinationSelectorName) {
+        getConfiguration().setReplyToDestinationSelectorName(replyToDestinationSelectorName);
+    }
+
+    public void setReplyToTempDestinationAffinity(String replyToTempDestinationAffinity) {
+        getConfiguration().setReplyToTempDestinationAffinity(replyToTempDestinationAffinity);
+    }
+
+    public void setRequestMapPurgePollTimeMillis(long requestMapPurgePollTimeMillis) {
+        getConfiguration().setRequestMapPurgePollTimeMillis(requestMapPurgePollTimeMillis);
+    }
+
+    public void setRequestTimeout(long requestTimeout) {
+        getConfiguration().setRequestTimeout(requestTimeout);
+    }
+
+    public void setSubscriptionDurable(boolean subscriptionDurable) {
+        getConfiguration().setSubscriptionDurable(subscriptionDurable);
+    }
+
+    public void setTaskExecutor(TaskExecutor taskExecutor) {
+        getConfiguration().setTaskExecutor(taskExecutor);
+    }
+
+    public void setTemplateConnectionFactory(ConnectionFactory templateConnectionFactory) {
+        getConfiguration().setTemplateConnectionFactory(templateConnectionFactory);
+    }
+
+    public void setTimeToLive(long timeToLive) {
+        getConfiguration().setTimeToLive(timeToLive);
+    }
+
+    public void setTransacted(boolean consumerTransacted) {
+        getConfiguration().setTransacted(consumerTransacted);
+    }
+
+    public void setTransactedInOut(boolean transactedInOut) {
+        getConfiguration().setTransactedInOut(transactedInOut);
+    }
+
+    public void setTransactionManager(PlatformTransactionManager transactionManager) {
+        getConfiguration().setTransactionManager(transactionManager);
+    }
+
+    public void setTransactionName(String transactionName) {
+        getConfiguration().setTransactionName(transactionName);
+    }
+
+    public void setTransactionTimeout(int transactionTimeout) {
+        getConfiguration().setTransactionTimeout(transactionTimeout);
+    }
+
+    public void setUseMessageIDAsCorrelationID(boolean useMessageIDAsCorrelationID) {
+        getConfiguration().setUseMessageIDAsCorrelationID(useMessageIDAsCorrelationID);
+    }
+
+    public void setUseVersion102(boolean useVersion102) {
+        getConfiguration().setUseVersion102(useVersion102);
+    }
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+
+    @Override
+    protected String createEndpointUri() {
+        String scheme = "jms";
+        Component owner = getComponent();
+        if (owner != null) {
+            // TODO get the scheme of the component?
+        }
+        if (destination != null) {
+            return scheme + ":" + destination;
+        }
+        else
+        if (destinationName != null) {
+            return scheme + ":" + destinationName;
+        }
+        DestinationResolver resolver = getDestinationResolver();
+        if (resolver != null) {
+            return scheme + ":" + resolver;
+        }
+        return super.createEndpointUri();
+    }
 }

Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java?rev=724380&r1=724379&r2=724380&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java (original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java Mon Dec  8 07:40:15 2008
@@ -146,6 +146,8 @@
     public void process(final Exchange exchange) {
         final org.apache.camel.Message in = exchange.getIn();
 
+        String destinationName = endpoint.getDestinationName();
+        Destination destination = endpoint.getDestination();
         if (exchange.getPattern().isOutCapable()) {
 
             testAndSetRequestor();
@@ -169,7 +171,7 @@
             final DeferredMessageSentCallback callback = msgIdAsCorrId ? deferredRequestReplyMap.createDeferredMessageSentCallback() : null;
 
             final CamelJmsTemplate template = (CamelJmsTemplate)getInOutTemplate();
-            template.send(endpoint.getDestination(), new MessageCreator() {
+            MessageCreator messageCreator = new MessageCreator() {
                 public Message createMessage(Session session) throws JMSException {
                     Message message = endpoint.getBinding().makeJmsMessage(exchange, in, session);
                     message.setJMSReplyTo(replyTo);
@@ -177,7 +179,7 @@
 
                     FutureTask future = null;
                     future = (!msgIdAsCorrId)
-                        ? requestor.getReceiveFuture(message.getJMSCorrelationID(), endpoint.getConfiguration().getRequestTimeout())
+                            ? requestor.getReceiveFuture(message.getJMSCorrelationID(), endpoint.getConfiguration().getRequestTimeout())
                             : requestor.getReceiveFuture(callback);
 
                     futureHolder.set(future);
@@ -187,7 +189,19 @@
                     }
                     return message;
                 }
-            }, callback);
+            };
+
+            if (destinationName != null) {
+                template.send(destinationName, messageCreator, callback);
+            }
+            else if (destination != null) {
+                // TODO cannot pass in callback using destination?
+                template.send(destination.toString(), messageCreator, callback);
+                // template.send(destination, messageCreator);
+            }
+            else {
+                throw new IllegalArgumentException("Neither destination nor destinationName is specified on this endpoint: " + endpoint);
+            }
 
             setMessageId(exchange);
 
@@ -224,7 +238,7 @@
                 exchange.setException(e);
             }
         } else {
-            getInOnlyTemplate().send(endpoint.getDestination(), new MessageCreator() {
+            MessageCreator messageCreator = new MessageCreator() {
                 public Message createMessage(Session session) throws JMSException {
                     Message message = endpoint.getBinding().makeJmsMessage(exchange, in, session);
                     if (LOG.isDebugEnabled()) {
@@ -232,7 +246,16 @@
                     }
                     return message;
                 }
-            });
+            };
+            if (destinationName != null) {
+                getInOnlyTemplate().send(destinationName, messageCreator);
+            }
+            else if (destination != null) {
+                getInOnlyTemplate().send(destination, messageCreator);
+            }
+            else {
+                throw new IllegalArgumentException("Neither destination nor destinationName is specified on this endpoint: " + endpoint);
+            }
 
             setMessageId(exchange);
         }

Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java?rev=724380&r1=724379&r2=724380&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java Mon Dec  8 07:40:15 2008
@@ -81,7 +81,7 @@
         if (queueBrowseStrategy == null) {
             return Collections.EMPTY_LIST;
         }
-        String queue = getDestination();
+        String queue = getDestinationName();
         JmsOperations template = getConfiguration().createInOnlyTemplate(this, false, queue);
         return queueBrowseStrategy.browse(template, queue, this);
     }

Added: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest.java?rev=724380&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest.java (added)
+++ activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest.java Mon Dec  8 07:40:15 2008
@@ -0,0 +1,54 @@
+/**
+ *
+ * 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.config;
+
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@ContextConfiguration
+public class JmsEndpointWithCustomDestinationTest extends AbstractJUnit38SpringContextTests {
+    @Produce(uri = "direct:start")
+    protected ProducerTemplate template;
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint result;
+    @Autowired
+    protected ActiveMQQueue jmsQueue;
+
+    private Object expectedBody = "<hello>world!</hello>";
+
+    public void testMessageSentToCustomEndpoint() throws Exception {
+        assertNotNull("jmsQueue", jmsQueue);
+        assertEquals("jmsqueue.getPhysicalName()", "Test.Camel.CustomEndpoint", jmsQueue.getPhysicalName());
+
+        result.expectedBodiesReceived(expectedBody);
+
+        template.sendBody(expectedBody);
+
+        result.assertIsSatisfied();
+    }
+
+}

Propchange: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest-context.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest-context.xml?rev=724380&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest-context.xml (added)
+++ activemq/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest-context.xml Mon Dec  8 07:40:15 2008
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<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.5.xsd
+         http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+
+  <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+    <route>
+      <from uri="direct:start"/>
+      <to ref="customJmsEndpoint"/>
+    </route>
+    <route>
+      <from ref="customJmsEndpoint"/>
+      <to uri="mock:result"/>
+    </route>
+  </camelContext>
+
+  <bean id="customJmsEndpoint" class="org.apache.camel.component.jms.JmsEndpoint">
+    <property name="connectionFactory">
+      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
+        <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
+      </bean>
+    </property>
+
+    <!-- lets specify the exact JMS destination to use -->
+    <property name="destination" ref="jmsQueue"/>
+  </bean>
+
+  <bean id="jmsQueue" class="org.apache.activemq.command.ActiveMQQueue">
+    <property name="physicalName" value="Test.Camel.CustomEndpoint"/>
+  </bean>
+</beans>

Propchange: activemq/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/config/JmsEndpointWithCustomDestinationTest-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native