[ 
https://issues.apache.org/jira/browse/CAMEL-12869?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16689187#comment-16689187
 ] 

ASF GitHub Bot commented on CAMEL-12869:
----------------------------------------

dmvolod closed pull request #2618: CAMEL-12869: ReplyTo destination must match 
endpoint type (topic or queue) that the message is sent on
URL: https://github.com/apache/camel/pull/2618
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/components/camel-sjms/src/main/docs/sjms-component.adoc 
b/components/camel-sjms/src/main/docs/sjms-component.adoc
index 6e9ad12f220..bff4665a164 100644
--- a/components/camel-sjms/src/main/docs/sjms-component.adoc
+++ b/components/camel-sjms/src/main/docs/sjms-component.adoc
@@ -150,7 +150,7 @@ with the following path and query parameters:
 | *exceptionHandler* (consumer) | To let the consumer use a custom 
ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this 
option is not in use. By default the consumer will deal with exceptions, that 
will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer 
creates an exchange. |  | ExchangePattern
 | *messageSelector* (consumer) | Sets the JMS Message selector syntax. |  | 
String
-| *namedReplyTo* (producer) | Sets the reply to destination name used for 
InOut producer endpoints. |  | String
+| *namedReplyTo* (producer) | Sets the reply to destination name used for 
InOut producer endpoints. The type of the reply to destination can be 
determined by the starting prefix (topic: or queue:) in its name. |  | String
 | *persistent* (producer) | Flag used to enable/disable message persistence. | 
true | boolean
 | *producerCount* (producer) | Sets the number of producers used for this 
endpoint. | 1 | int
 | *ttl* (producer) | Flag used to adjust the Time To Live value of produced 
messages. | -1 | long
diff --git 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsEndpoint.java
 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsEndpoint.java
index c73ebb0847a..faa01d0e62b 100644
--- 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsEndpoint.java
+++ 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/SjmsEndpoint.java
@@ -563,6 +563,8 @@ public String getNamedReplyTo() {
 
     /**
      * Sets the reply to destination name used for InOut producer endpoints.
+     * The type of the reply to destination can be determined by the starting 
+     * prefix (topic: or queue:) in its name. 
      */
     public void setNamedReplyTo(String namedReplyTo) {
         this.namedReplyTo = namedReplyTo;
diff --git 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DestinationNameParser.java
 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DestinationNameParser.java
index 41eab2d089e..095d1c991b2 100644
--- 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DestinationNameParser.java
+++ 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/DestinationNameParser.java
@@ -27,6 +27,19 @@ public boolean isTopic(String destinationName) {
         }
         return destinationName.startsWith("topic:");
     }
+    
+    public boolean isNamedReplyToTopic(String namedReplyTo, boolean 
isDestinationTopic) {
+        if (namedReplyTo == null) {
+            throw new IllegalArgumentException("namedReplyTo is null");
+        }
+        if (namedReplyTo.startsWith("topic:")) {
+            return true;
+        } else if (namedReplyTo.startsWith("queue:")) {
+            return false;
+        } else {
+            return isDestinationTopic;
+        }
+    }
 
     public String getShortName(String destinationName) {
         if (destinationName == null) {
diff --git 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/producer/InOutProducer.java
 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/producer/InOutProducer.java
index 1be3630e370..53be09eca72 100644
--- 
a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/producer/InOutProducer.java
+++ 
b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/producer/InOutProducer.java
@@ -38,6 +38,7 @@
 import org.apache.camel.component.sjms.SjmsMessage;
 import org.apache.camel.component.sjms.SjmsProducer;
 import org.apache.camel.component.sjms.jms.ConnectionResource;
+import org.apache.camel.component.sjms.jms.DestinationNameParser;
 import org.apache.camel.component.sjms.jms.JmsConstants;
 import org.apache.camel.component.sjms.jms.JmsMessageHelper;
 import org.apache.camel.spi.UuidGenerator;
@@ -87,12 +88,16 @@ public MessageConsumerResources makeObject() throws 
Exception {
                 }
 
                 Destination replyToDestination;
+                boolean isReplyToTopic = false;
                 if (ObjectHelper.isEmpty(getNamedReplyTo())) {
-                    replyToDestination = 
getEndpoint().getDestinationCreationStrategy().createTemporaryDestination(session,
 isTopic());
+                    isReplyToTopic = isTopic();
+                    replyToDestination = 
getEndpoint().getDestinationCreationStrategy().createTemporaryDestination(session,
 isReplyToTopic);
                 } else {
-                    replyToDestination = 
getEndpoint().getDestinationCreationStrategy().createDestination(session, 
getNamedReplyTo(), isTopic());
+                    DestinationNameParser parser = new DestinationNameParser();
+                    isReplyToTopic = 
parser.isNamedReplyToTopic(getNamedReplyTo(), isTopic());
+                    replyToDestination = 
getEndpoint().getDestinationCreationStrategy().createDestination(session, 
getNamedReplyTo(), isReplyToTopic);
                 }
-                MessageConsumer messageConsumer = 
getEndpoint().getJmsObjectFactory().createMessageConsumer(session, 
replyToDestination, null, isTopic(), null, true, false, false);
+                MessageConsumer messageConsumer = 
getEndpoint().getJmsObjectFactory().createMessageConsumer(session, 
replyToDestination, null, isReplyToTopic, null, true, false, false);
                 messageConsumer.setMessageListener(new MessageListener() {
                     @Override
                     public void onMessage(final Message message) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> ReplyTo destination must match endpoint type (topic or queue) that the 
> message is sent on
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-12869
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12869
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-sjms
>    Affects Versions: 2.22.1
>            Reporter: Shannon Gallagher
>            Assignee: Dmitry Volodin
>            Priority: Major
>             Fix For: 2.23.0
>
>
>  
> When setting the namedReplyTo attribute on an endpoint, the reply to 
> destination always gets created with the same type (topic or queue) as the 
> endpoint. When configuring routes using the namedReplyTo in the URI, there is 
> no way to make the reply to destination a topic if the endpoint is a queue, 
> or a queue if the endpoint is a topic.
> It seems that there should be some way to indicate in the namedReplyTo value 
> if the reply to destination should be a topic or queue.
> As an example, I've been looking at the InOutQueueProducerSyncLoadTest and 
> seeing that when creating the reply to destination, InOutProducer.java (line 
> 93) uses the endpoint's isTopic() value to indicate whether the destination 
> should be a topic or a queue. Maybe the topic flag should be determined based 
> on the value of namedReplyTo so it does not always have to be the same type 
> as the endpoint.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to