001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.camel.component.jms; 018 019 import javax.jms.ConnectionFactory; 020 import javax.jms.Destination; 021 import javax.jms.ExceptionListener; 022 import javax.jms.JMSException; 023 import javax.jms.Message; 024 import javax.jms.Queue; 025 import javax.jms.TemporaryQueue; 026 import javax.jms.TemporaryTopic; 027 import javax.jms.Topic; 028 029 import org.apache.camel.Component; 030 import org.apache.camel.Exchange; 031 import org.apache.camel.ExchangePattern; 032 import org.apache.camel.PollingConsumer; 033 import org.apache.camel.Processor; 034 import org.apache.camel.component.jms.requestor.Requestor; 035 import org.apache.camel.impl.DefaultEndpoint; 036 import org.apache.camel.impl.DefaultExchange; 037 import org.apache.camel.spi.HeaderFilterStrategy; 038 import org.apache.camel.spi.HeaderFilterStrategyAware; 039 import org.springframework.core.task.TaskExecutor; 040 import org.springframework.jms.core.JmsOperations; 041 import org.springframework.jms.core.JmsTemplate; 042 import org.springframework.jms.listener.AbstractMessageListenerContainer; 043 import org.springframework.jms.support.converter.MessageConverter; 044 import org.springframework.jms.support.destination.DestinationResolver; 045 import org.springframework.transaction.PlatformTransactionManager; 046 047 /** 048 * A <a href="http://activemq.apache.org/jms.html">JMS Endpoint</a> 049 * 050 * @version $Revision:520964 $ 051 */ 052 public class JmsEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware { 053 private HeaderFilterStrategy headerFilterStrategy; 054 private boolean pubSubDomain; 055 private JmsBinding binding; 056 private String destinationName; 057 private Destination destination; 058 private String selector; 059 private JmsConfiguration configuration; 060 private Requestor requestor; 061 062 public JmsEndpoint() { 063 this(null, null); 064 } 065 066 public JmsEndpoint(Topic destination) throws JMSException { 067 this("jms:topic:" + destination.getTopicName(), null); 068 this.destination = destination; 069 } 070 071 public JmsEndpoint(String uri, JmsComponent component, String destinationName, boolean pubSubDomain, JmsConfiguration configuration) { 072 super(uri, component); 073 this.configuration = configuration; 074 this.destinationName = destinationName; 075 this.pubSubDomain = pubSubDomain; 076 } 077 078 public JmsEndpoint(String endpointUri, JmsBinding binding, JmsConfiguration configuration, String destinationName, boolean pubSubDomain) { 079 super(endpointUri); 080 this.binding = binding; 081 this.configuration = configuration; 082 this.destinationName = destinationName; 083 this.pubSubDomain = pubSubDomain; 084 } 085 086 public JmsEndpoint(String endpointUri, String destinationName, boolean pubSubDomain) { 087 this(endpointUri, new JmsBinding(), new JmsConfiguration(), destinationName, pubSubDomain); 088 } 089 090 /** 091 * Creates a pub-sub endpoint with the given destination 092 */ 093 public JmsEndpoint(String endpointUri, String destinationName) { 094 this(endpointUri, destinationName, true); 095 } 096 097 098 /** 099 * Returns a new JMS endpoint for the given JMS destination using the configuration from the given JMS component 100 */ 101 public static JmsEndpoint newInstance(Destination destination, JmsComponent component) throws JMSException { 102 JmsEndpoint answer = newInstance(destination); 103 JmsConfiguration newConfiguration = component.getConfiguration().copy(); 104 answer.setConfiguration(newConfiguration); 105 answer.setCamelContext(component.getCamelContext()); 106 return answer; 107 } 108 109 /** 110 * Returns a new JMS endpoint for the given JMS destination 111 */ 112 public static JmsEndpoint newInstance(Destination destination) throws JMSException { 113 if (destination instanceof TemporaryQueue) { 114 return new JmsTemporaryQueueEndpoint((TemporaryQueue) destination); 115 } 116 if (destination instanceof TemporaryTopic) { 117 return new JmsTemporaryTopicEndpoint((TemporaryTopic) destination); 118 } 119 if (destination instanceof Queue) { 120 return new JmsQueueEndpoint((Queue) destination); 121 } else { 122 return new JmsEndpoint((Topic) destination); 123 } 124 } 125 126 public JmsProducer createProducer() throws Exception { 127 return new JmsProducer(this); 128 } 129 130 /** 131 * Creates a producer using the given template for InOnly message exchanges 132 */ 133 public JmsProducer createProducer(JmsOperations template) throws Exception { 134 JmsProducer answer = createProducer(); 135 if (template instanceof JmsTemplate) { 136 JmsTemplate jmsTemplate = (JmsTemplate) template; 137 jmsTemplate.setPubSubDomain(pubSubDomain); 138 if (destinationName != null) { 139 jmsTemplate.setDefaultDestinationName(destinationName); 140 } else if (destination != null) { 141 jmsTemplate.setDefaultDestination(destination); 142 } 143 // TODO: Why is this destination resolver disabled for producer? Its enable for consumer! 144 /* 145 else { 146 DestinationResolver resolver = getDestinationResolver(); 147 if (resolver != null) { 148 jmsTemplate.setDestinationResolver(resolver); 149 } 150 else { 151 throw new IllegalArgumentException("Neither destination, destinationName or destinationResolver are specified on this endpoint!"); 152 } 153 } 154 */ 155 } 156 answer.setInOnlyTemplate(template); 157 return answer; 158 } 159 160 161 public JmsConsumer createConsumer(Processor processor) throws Exception { 162 AbstractMessageListenerContainer listenerContainer = configuration.createMessageListenerContainer(this); 163 return createConsumer(processor, listenerContainer); 164 } 165 166 /** 167 * Creates a consumer using the given processor and listener container 168 * 169 * @param processor the processor to use to process the messages 170 * @param listenerContainer the listener container 171 * @return a newly created consumer 172 * @throws Exception if the consumer cannot be created 173 */ 174 public JmsConsumer createConsumer(Processor processor, AbstractMessageListenerContainer listenerContainer) throws Exception { 175 if (destinationName != null) { 176 listenerContainer.setDestinationName(destinationName); 177 } else if (destination != null) { 178 listenerContainer.setDestination(destination); 179 } else { 180 DestinationResolver resolver = getDestinationResolver(); 181 if (resolver != null) { 182 listenerContainer.setDestinationResolver(resolver); 183 } else { 184 throw new IllegalArgumentException("Neither destination, destinationName or destinationResolver are specified on this endpoint!"); 185 } 186 } 187 listenerContainer.setPubSubDomain(pubSubDomain); 188 return new JmsConsumer(this, processor, listenerContainer); 189 } 190 191 @Override 192 public PollingConsumer createPollingConsumer() throws Exception { 193 JmsOperations template = createInOnlyTemplate(); 194 return new JmsPollingConsumer(this, template); 195 } 196 197 @Override 198 public Exchange createExchange(ExchangePattern pattern) { 199 Exchange exchange = new DefaultExchange(this, pattern); 200 exchange.setProperty(Exchange.BINDING, getBinding()); 201 return exchange; 202 } 203 204 public Exchange createExchange(Message message) { 205 Exchange exchange = createExchange(getExchangePattern()); 206 exchange.setIn(new JmsMessage(message)); 207 return exchange; 208 } 209 210 /** 211 * Factory method for creating a new template for InOnly message exchanges 212 */ 213 public JmsOperations createInOnlyTemplate() { 214 return configuration.createInOnlyTemplate(this, pubSubDomain, destinationName); 215 } 216 217 /** 218 * Factory method for creating a new template for InOut message exchanges 219 */ 220 public JmsOperations createInOutTemplate() { 221 return configuration.createInOutTemplate(this, pubSubDomain, destinationName, configuration.getRequestTimeout()); 222 } 223 224 // Properties 225 // ------------------------------------------------------------------------- 226 public HeaderFilterStrategy getHeaderFilterStrategy() { 227 if (headerFilterStrategy == null) { 228 headerFilterStrategy = new JmsHeaderFilterStrategy(); 229 } 230 return headerFilterStrategy; 231 } 232 233 public void setHeaderFilterStrategy(HeaderFilterStrategy strategy) { 234 this.headerFilterStrategy = strategy; 235 } 236 237 public JmsBinding getBinding() { 238 if (binding == null) { 239 binding = new JmsBinding(this); 240 } 241 return binding; 242 } 243 244 /** 245 * Sets the binding used to convert from a Camel message to and from a JMS 246 * message 247 * 248 * @param binding the binding to use 249 */ 250 public void setBinding(JmsBinding binding) { 251 this.binding = binding; 252 } 253 254 public String getDestinationName() { 255 return destinationName; 256 } 257 258 public void setDestinationName(String destinationName) { 259 this.destinationName = destinationName; 260 } 261 262 public Destination getDestination() { 263 return destination; 264 } 265 266 /** 267 * Allows a specific JMS Destination object to be used as the destination 268 */ 269 public void setDestination(Destination destination) { 270 this.destination = destination; 271 } 272 273 public JmsConfiguration getConfiguration() { 274 return configuration; 275 } 276 277 public void setConfiguration(JmsConfiguration configuration) { 278 this.configuration = configuration; 279 } 280 281 public String getSelector() { 282 return selector; 283 } 284 285 /** 286 * Sets the JMS selector to use 287 */ 288 public void setSelector(String selector) { 289 this.selector = selector; 290 } 291 292 public boolean isSingleton() { 293 return false; 294 } 295 296 public synchronized Requestor getRequestor() throws Exception { 297 if (requestor == null) { 298 requestor = new Requestor(getConfiguration(), getScheduledExecutorService()); 299 requestor.start(); 300 } 301 return requestor; 302 } 303 304 public void setRequestor(Requestor requestor) { 305 this.requestor = requestor; 306 } 307 308 public boolean isPubSubDomain() { 309 return pubSubDomain; 310 } 311 312 /** 313 * Lazily loads the temporary queue type if one has not been explicitly configured 314 * via calling the {@link JmsProviderMetadata#setTemporaryQueueType(Class)} 315 * on the {@link #getConfiguration()} instance 316 */ 317 public Class<? extends TemporaryQueue> getTemporaryQueueType() { 318 JmsProviderMetadata metadata = getProviderMetadata(); 319 JmsOperations template = getMetadataJmsOperations(); 320 return metadata.getTemporaryQueueType(template); 321 } 322 323 /** 324 * Lazily loads the temporary topic type if one has not been explicitly configured 325 * via calling the {@link JmsProviderMetadata#setTemporaryTopicType(Class)} 326 * on the {@link #getConfiguration()} instance 327 */ 328 public Class<? extends TemporaryTopic> getTemporaryTopicType() { 329 JmsOperations template = getMetadataJmsOperations(); 330 JmsProviderMetadata metadata = getProviderMetadata(); 331 return metadata.getTemporaryTopicType(template); 332 } 333 334 /** 335 * Returns the provider metadata 336 */ 337 protected JmsProviderMetadata getProviderMetadata() { 338 JmsConfiguration conf = getConfiguration(); 339 JmsProviderMetadata metadata = conf.getProviderMetadata(); 340 return metadata; 341 } 342 343 344 /** 345 * Returns the {@link JmsOperations} used for metadata operations such as creating temporary destinations 346 */ 347 protected JmsOperations getMetadataJmsOperations() { 348 JmsOperations template = getConfiguration().getMetadataJmsOperations(this); 349 if (template == null) { 350 throw new IllegalArgumentException("No Metadata JmsTemplate supplied!"); 351 } 352 return template; 353 } 354 355 public void checkValidTemplate(JmsTemplate template) { 356 if (template.getDestinationResolver() == null) { 357 if (this instanceof DestinationEndpoint) { 358 final DestinationEndpoint destinationEndpoint = (DestinationEndpoint) this; 359 template.setDestinationResolver(JmsConfiguration.createDestinationResolver(destinationEndpoint)); 360 } 361 } 362 } 363 364 // Delegated properties from the configuration 365 //------------------------------------------------------------------------- 366 public int getAcknowledgementMode() { 367 return getConfiguration().getAcknowledgementMode(); 368 } 369 370 public String getAcknowledgementModeName() { 371 return getConfiguration().getAcknowledgementModeName(); 372 } 373 374 public int getCacheLevel() { 375 return getConfiguration().getCacheLevel(); 376 } 377 378 public String getCacheLevelName() { 379 return getConfiguration().getCacheLevelName(); 380 } 381 382 public String getClientId() { 383 return getConfiguration().getClientId(); 384 } 385 386 public int getConcurrentConsumers() { 387 return getConfiguration().getConcurrentConsumers(); 388 } 389 390 public ConnectionFactory getConnectionFactory() { 391 return getConfiguration().getConnectionFactory(); 392 } 393 394 public ConsumerType getConsumerType() { 395 return getConfiguration().getConsumerType(); 396 } 397 398 public DestinationResolver getDestinationResolver() { 399 return getConfiguration().getDestinationResolver(); 400 } 401 402 public String getDurableSubscriptionName() { 403 return getConfiguration().getDurableSubscriptionName(); 404 } 405 406 public ExceptionListener getExceptionListener() { 407 return getConfiguration().getExceptionListener(); 408 } 409 410 public int getIdleTaskExecutionLimit() { 411 return getConfiguration().getIdleTaskExecutionLimit(); 412 } 413 414 public JmsOperations getJmsOperations() { 415 return getConfiguration().getJmsOperations(); 416 } 417 418 public ConnectionFactory getListenerConnectionFactory() { 419 return getConfiguration().getListenerConnectionFactory(); 420 } 421 422 public int getMaxConcurrentConsumers() { 423 return getConfiguration().getMaxConcurrentConsumers(); 424 } 425 426 public int getMaxMessagesPerTask() { 427 return getConfiguration().getMaxMessagesPerTask(); 428 } 429 430 public MessageConverter getMessageConverter() { 431 return getConfiguration().getMessageConverter(); 432 } 433 434 public JmsOperations getMetadataJmsOperations(JmsEndpoint endpoint) { 435 return getConfiguration().getMetadataJmsOperations(endpoint); 436 } 437 438 public int getPriority() { 439 return getConfiguration().getPriority(); 440 } 441 442 public long getReceiveTimeout() { 443 return getConfiguration().getReceiveTimeout(); 444 } 445 446 public long getRecoveryInterval() { 447 return getConfiguration().getRecoveryInterval(); 448 } 449 450 public String getReplyTo() { 451 return getConfiguration().getReplyTo(); 452 } 453 454 public String getReplyToDestinationSelectorName() { 455 return getConfiguration().getReplyToDestinationSelectorName(); 456 } 457 458 public String getReplyToTempDestinationAffinity() { 459 return getConfiguration().getReplyToTempDestinationAffinity(); 460 } 461 462 public long getRequestMapPurgePollTimeMillis() { 463 return getConfiguration().getRequestMapPurgePollTimeMillis(); 464 } 465 466 public long getRequestTimeout() { 467 return getConfiguration().getRequestTimeout(); 468 } 469 470 public TaskExecutor getTaskExecutor() { 471 return getConfiguration().getTaskExecutor(); 472 } 473 474 public ConnectionFactory getTemplateConnectionFactory() { 475 return getConfiguration().getTemplateConnectionFactory(); 476 } 477 478 public long getTimeToLive() { 479 return getConfiguration().getTimeToLive(); 480 } 481 482 public PlatformTransactionManager getTransactionManager() { 483 return getConfiguration().getTransactionManager(); 484 } 485 486 public String getTransactionName() { 487 return getConfiguration().getTransactionName(); 488 } 489 490 public int getTransactionTimeout() { 491 return getConfiguration().getTransactionTimeout(); 492 } 493 494 public boolean isAcceptMessagesWhileStopping() { 495 return getConfiguration().isAcceptMessagesWhileStopping(); 496 } 497 498 public boolean isAlwaysCopyMessage() { 499 return getConfiguration().isAlwaysCopyMessage(); 500 } 501 502 public boolean isAutoStartup() { 503 return getConfiguration().isAutoStartup(); 504 } 505 506 public boolean isDeliveryPersistent() { 507 return getConfiguration().isDeliveryPersistent(); 508 } 509 510 public boolean isDisableReplyTo() { 511 return getConfiguration().isDisableReplyTo(); 512 } 513 514 public boolean isEagerLoadingOfProperties() { 515 return getConfiguration().isEagerLoadingOfProperties(); 516 } 517 518 public boolean isExplicitQosEnabled() { 519 return getConfiguration().isExplicitQosEnabled(); 520 } 521 522 public boolean isExposeListenerSession() { 523 return getConfiguration().isExposeListenerSession(); 524 } 525 526 public boolean isMessageIdEnabled() { 527 return getConfiguration().isMessageIdEnabled(); 528 } 529 530 public boolean isMessageTimestampEnabled() { 531 return getConfiguration().isMessageTimestampEnabled(); 532 } 533 534 public boolean isPreserveMessageQos() { 535 return getConfiguration().isPreserveMessageQos(); 536 } 537 538 public boolean isPubSubNoLocal() { 539 return getConfiguration().isPubSubNoLocal(); 540 } 541 542 public boolean isReplyToDeliveryPersistent() { 543 return getConfiguration().isReplyToDeliveryPersistent(); 544 } 545 546 public boolean isSubscriptionDurable() { 547 return getConfiguration().isSubscriptionDurable(); 548 } 549 550 public boolean isTransacted() { 551 return getConfiguration().isTransacted(); 552 } 553 554 public boolean isTransactedInOut() { 555 return getConfiguration().isTransactedInOut(); 556 } 557 558 public boolean isUseMessageIDAsCorrelationID() { 559 return getConfiguration().isUseMessageIDAsCorrelationID(); 560 } 561 562 public boolean isUseVersion102() { 563 return getConfiguration().isUseVersion102(); 564 } 565 566 public void setAcceptMessagesWhileStopping(boolean acceptMessagesWhileStopping) { 567 getConfiguration().setAcceptMessagesWhileStopping(acceptMessagesWhileStopping); 568 } 569 570 public void setAcknowledgementMode(int consumerAcknowledgementMode) { 571 getConfiguration().setAcknowledgementMode(consumerAcknowledgementMode); 572 } 573 574 public void setAcknowledgementModeName(String consumerAcknowledgementMode) { 575 getConfiguration().setAcknowledgementModeName(consumerAcknowledgementMode); 576 } 577 578 public void setAlwaysCopyMessage(boolean alwaysCopyMessage) { 579 getConfiguration().setAlwaysCopyMessage(alwaysCopyMessage); 580 } 581 582 public void setAutoStartup(boolean autoStartup) { 583 getConfiguration().setAutoStartup(autoStartup); 584 } 585 586 public void setCacheLevel(int cacheLevel) { 587 getConfiguration().setCacheLevel(cacheLevel); 588 } 589 590 public void setCacheLevelName(String cacheName) { 591 getConfiguration().setCacheLevelName(cacheName); 592 } 593 594 public void setClientId(String consumerClientId) { 595 getConfiguration().setClientId(consumerClientId); 596 } 597 598 public void setConcurrentConsumers(int concurrentConsumers) { 599 getConfiguration().setConcurrentConsumers(concurrentConsumers); 600 } 601 602 public void setConnectionFactory(ConnectionFactory connectionFactory) { 603 getConfiguration().setConnectionFactory(connectionFactory); 604 } 605 606 public void setConsumerType(ConsumerType consumerType) { 607 getConfiguration().setConsumerType(consumerType); 608 } 609 610 public void setDeliveryPersistent(boolean deliveryPersistent) { 611 getConfiguration().setDeliveryPersistent(deliveryPersistent); 612 } 613 614 public void setDestinationResolver(DestinationResolver destinationResolver) { 615 getConfiguration().setDestinationResolver(destinationResolver); 616 } 617 618 619 public void setDisableReplyTo(boolean disableReplyTo) { 620 getConfiguration().setDisableReplyTo(disableReplyTo); 621 } 622 623 public void setDurableSubscriptionName(String durableSubscriptionName) { 624 getConfiguration().setDurableSubscriptionName(durableSubscriptionName); 625 } 626 627 public void setEagerLoadingOfProperties(boolean eagerLoadingOfProperties) { 628 getConfiguration().setEagerLoadingOfProperties(eagerLoadingOfProperties); 629 } 630 631 public void setExceptionListener(ExceptionListener exceptionListener) { 632 getConfiguration().setExceptionListener(exceptionListener); 633 } 634 635 public void setExplicitQosEnabled(boolean explicitQosEnabled) { 636 getConfiguration().setExplicitQosEnabled(explicitQosEnabled); 637 } 638 639 public void setExposeListenerSession(boolean exposeListenerSession) { 640 getConfiguration().setExposeListenerSession(exposeListenerSession); 641 } 642 643 public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit) { 644 getConfiguration().setIdleTaskExecutionLimit(idleTaskExecutionLimit); 645 } 646 647 public void setJmsOperations(JmsOperations jmsOperations) { 648 getConfiguration().setJmsOperations(jmsOperations); 649 } 650 651 public void setListenerConnectionFactory(ConnectionFactory listenerConnectionFactory) { 652 getConfiguration().setListenerConnectionFactory(listenerConnectionFactory); 653 } 654 655 public void setMaxConcurrentConsumers(int maxConcurrentConsumers) { 656 getConfiguration().setMaxConcurrentConsumers(maxConcurrentConsumers); 657 } 658 659 public void setMaxMessagesPerTask(int maxMessagesPerTask) { 660 getConfiguration().setMaxMessagesPerTask(maxMessagesPerTask); 661 } 662 663 public void setMessageConverter(MessageConverter messageConverter) { 664 getConfiguration().setMessageConverter(messageConverter); 665 } 666 667 public void setMessageIdEnabled(boolean messageIdEnabled) { 668 getConfiguration().setMessageIdEnabled(messageIdEnabled); 669 } 670 671 public void setMessageTimestampEnabled(boolean messageTimestampEnabled) { 672 getConfiguration().setMessageTimestampEnabled(messageTimestampEnabled); 673 } 674 675 public void setMetadataJmsOperations(JmsOperations metadataJmsOperations) { 676 getConfiguration().setMetadataJmsOperations(metadataJmsOperations); 677 } 678 679 public void setPreserveMessageQos(boolean preserveMessageQos) { 680 getConfiguration().setPreserveMessageQos(preserveMessageQos); 681 } 682 683 public void setPriority(int priority) { 684 getConfiguration().setPriority(priority); 685 } 686 687 public void setProviderMetadata(JmsProviderMetadata providerMetadata) { 688 getConfiguration().setProviderMetadata(providerMetadata); 689 } 690 691 public void setPubSubNoLocal(boolean pubSubNoLocal) { 692 getConfiguration().setPubSubNoLocal(pubSubNoLocal); 693 } 694 695 public void setReceiveTimeout(long receiveTimeout) { 696 getConfiguration().setReceiveTimeout(receiveTimeout); 697 } 698 699 public void setRecoveryInterval(long recoveryInterval) { 700 getConfiguration().setRecoveryInterval(recoveryInterval); 701 } 702 703 public void setReplyTo(String replyToDestination) { 704 getConfiguration().setReplyTo(replyToDestination); 705 } 706 707 public void setReplyToDeliveryPersistent(boolean replyToDeliveryPersistent) { 708 getConfiguration().setReplyToDeliveryPersistent(replyToDeliveryPersistent); 709 } 710 711 public void setReplyToDestinationSelectorName(String replyToDestinationSelectorName) { 712 getConfiguration().setReplyToDestinationSelectorName(replyToDestinationSelectorName); 713 } 714 715 public void setReplyToTempDestinationAffinity(String replyToTempDestinationAffinity) { 716 getConfiguration().setReplyToTempDestinationAffinity(replyToTempDestinationAffinity); 717 } 718 719 public void setRequestMapPurgePollTimeMillis(long requestMapPurgePollTimeMillis) { 720 getConfiguration().setRequestMapPurgePollTimeMillis(requestMapPurgePollTimeMillis); 721 } 722 723 public void setRequestTimeout(long requestTimeout) { 724 getConfiguration().setRequestTimeout(requestTimeout); 725 } 726 727 public void setSubscriptionDurable(boolean subscriptionDurable) { 728 getConfiguration().setSubscriptionDurable(subscriptionDurable); 729 } 730 731 public void setTaskExecutor(TaskExecutor taskExecutor) { 732 getConfiguration().setTaskExecutor(taskExecutor); 733 } 734 735 public void setTemplateConnectionFactory(ConnectionFactory templateConnectionFactory) { 736 getConfiguration().setTemplateConnectionFactory(templateConnectionFactory); 737 } 738 739 public void setTimeToLive(long timeToLive) { 740 getConfiguration().setTimeToLive(timeToLive); 741 } 742 743 public void setTransacted(boolean consumerTransacted) { 744 getConfiguration().setTransacted(consumerTransacted); 745 } 746 747 public void setTransactedInOut(boolean transactedInOut) { 748 getConfiguration().setTransactedInOut(transactedInOut); 749 } 750 751 public void setTransactionManager(PlatformTransactionManager transactionManager) { 752 getConfiguration().setTransactionManager(transactionManager); 753 } 754 755 public void setTransactionName(String transactionName) { 756 getConfiguration().setTransactionName(transactionName); 757 } 758 759 public void setTransactionTimeout(int transactionTimeout) { 760 getConfiguration().setTransactionTimeout(transactionTimeout); 761 } 762 763 public void setUseMessageIDAsCorrelationID(boolean useMessageIDAsCorrelationID) { 764 getConfiguration().setUseMessageIDAsCorrelationID(useMessageIDAsCorrelationID); 765 } 766 767 public void setUseVersion102(boolean useVersion102) { 768 getConfiguration().setUseVersion102(useVersion102); 769 } 770 771 public JmsMessageType getJmsMessageType() { 772 return getConfiguration().getJmsMessageType(); 773 } 774 775 public void setJmsMessageType(JmsMessageType jmsMessageType) { 776 getConfiguration().setJmsMessageType(jmsMessageType); 777 } 778 779 public JmsKeyFormatStrategy getJmsKeyFormatStrategy() { 780 return getConfiguration().getJmsKeyFormatStrategy(); 781 } 782 783 public void setJmsKeyFormatStrategy(JmsKeyFormatStrategy jmsHeaderStrategy) { 784 getConfiguration().setJmsKeyFormatStrategy(jmsHeaderStrategy); 785 } 786 787 public boolean isTransferExchange() { 788 return getConfiguration().isTransferExchange(); 789 } 790 791 public void setTransferExchange(boolean transferExchange) { 792 getConfiguration().setTransferExchange(transferExchange); 793 } 794 795 public boolean isTransferException() { 796 return getConfiguration().isTransferException(); 797 } 798 799 public void setTransferException(boolean transferException) { 800 getConfiguration().setTransferException(transferException); 801 } 802 803 // Implementation methods 804 //------------------------------------------------------------------------- 805 806 @Override 807 protected String createEndpointUri() { 808 String scheme = "jms"; 809 Component owner = getComponent(); 810 if (owner != null) { 811 // TODO get the scheme of the component? 812 } 813 if (destination != null) { 814 return scheme + ":" + destination; 815 } else if (destinationName != null) { 816 return scheme + ":" + destinationName; 817 } 818 DestinationResolver resolver = getDestinationResolver(); 819 if (resolver != null) { 820 return scheme + ":" + resolver; 821 } 822 return super.createEndpointUri(); 823 } 824 825 }