# solace\_replyto header is failed to retrieve in spring cloud stream

**URL:** <https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957>\
**Category:** Connectors & Integrations\
**Created:** [September 27, 2021, 4:04pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957 "2021-09-27T16:04:53Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![as63010](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@as63010](https://community.solace.com/u/as63010)\
**Post date:** [September 27, 2021, 4:04pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/1 "2021-09-27T16:04:53Z")

</div>

Hi Team,

We are getting the below error when get the solace\_replyto header. Please help to check.

Caused by: java.lang.IllegalArgumentException: Incorrect type specified for header ‘scst\_targetDestination’. Expected [class java.lang.String] but actual type is [class com.solacesystems.jcsmp.impl.TopicImpl]

---

<div class="post-metadata">

**Author:** ![marc](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/marc/32/2191_2.png) [@marc](https://community.solace.com/u/marc)\
**Post date:** [September 27, 2021, 5:03pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/2 "2021-09-27T17:03:37Z")

</div>

Hi @as63010,

It looks like you are trying to set the `scst_targetDestination` header directly to the value of the `solace_replyTo` header. The `solace_replyTo` header is actually of type `Destination` and not `String` so you have two options:

1. Cast `solace_replyTo` to a `Destination` type when reading it and use the `getName()` method to get the actual String representation of the name OR
2. If you’re using all Spring Cloud Stream apps you could use a different (custom) header to capture the topic the requestor wants the replier to respond on and just keep it as a `String` the whole time.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![as63010](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@as63010](https://community.solace.com/u/as63010)\
**Post date:** [September 27, 2021, 5:15pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/3 "2021-09-27T17:15:25Z")

</div>

Thanks Marc for your support

---

<div class="post-metadata">

**Author:** ![marc](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/marc/32/2191_2.png) [@marc](https://community.solace.com/u/marc)\
**Post date:** [September 27, 2021, 5:18pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/4 "2021-09-27T17:18:44Z")

</div>

No problem @as63010 - I should have also included that you can find more info on the headers available via the solace binder here: [solace-spring-cloud/solace-spring-cloud-starters/solace-spring-cloud-stream-starter at master · SolaceProducts/solace-spring-cloud · GitHub](https://github.com/SolaceProducts/solace-spring-cloud/tree/master/solace-spring-cloud-starters/solace-spring-cloud-stream-starter#solace-headers)

---

<div class="post-metadata">

**Author:** ![as63010](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@as63010](https://community.solace.com/u/as63010)\
**Post date:** [October 8, 2021, 7:04am UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/5 "2021-10-08T07:04:27Z")

</div>

Hi @Marc,  
When we reply to solace\_replyTo topic from spring cloud stream, message not received by requester. Any additional setting is required to reply?

---

<div class="post-metadata">

**Author:** ![as63010](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@as63010](https://community.solace.com/u/as63010)\
**Post date:** [October 8, 2021, 7:05am UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/6 "2021-10-08T07:05:30Z")

</div>

setHeader(BinderHeaders.TARGET\_DESTINATION,response.getHeaders().get(“solace\_replyTo”)).

---

<div class="post-metadata">

**Author:** ![as63010](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@as63010](https://community.solace.com/u/as63010)\
**Post date:** [October 14, 2021, 11:34am UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/7 "2021-10-14T11:34:14Z")

</div>

@Marc, Can you help this?

We are getting the replyTo topic name as below. Is it possible to put the message in reply topic using spring cloud stream?

solace\_replyTo=#P2P/v:solace-xxxx/nDOiG3j8/H17NDCFI13P0120/5084/#00130001/STsW9Glj1L/#

---

<div class="post-metadata">

**Author:** ![as63010](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@as63010](https://community.solace.com/u/as63010)\
**Post date:** [October 14, 2021, 11:46am UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/8 "2021-10-14T11:46:54Z")

</div>

@JamilAhmed Can you help this? We aren’t able to receive the reply from Orchestrator.  
We tried the below sample shared in github.

// Build the topics  
outputTopic = input.getHeaders().get(MEDIATOR\_REPLYTO\_DESTINATION\_KEY).toString();

Message output = MessageBuilder.withPayload(jsonMessageOut.toString())  
.setHeader(SOL\_CORRELATION\_ID\_KEY, input.getHeaders().getOrDefault(MEDIATOR\_CORRELATION\_ID\_KEY, “”))  
.setHeader(BinderHeaders.TARGET\_DESTINATION, outputTopic)  
.build();

---

<div class="post-metadata">

**Author:** ![JamilAhmed](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/jamilahmed/32/78_2.png) [@JamilAhmed](https://community.solace.com/u/JamilAhmed)\
**Post date:** [October 14, 2021, 11:53am UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/9 "2021-10-14T11:53:38Z")

</div>

Hi @as63010, looks like the `#P2P...` reply topic is correctly being fetched and set as the destination.  
In terms of the original request, is that another application using Solace APIs, or are you using the Microgateway feature to automatically convert a HTTP operation into a request message? If using microgateway, did you correctly set the REST mode in your message VPN to `gateway`? ([Docs Link](https://docs.solace.com/Configuring-and-Managing/Microgateway-Tasks/Managing-Microgateway.htm#Configure_VPN_Mode))

---

<div class="post-metadata">

**Author:** ![as63010](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@as63010](https://community.solace.com/u/as63010)\
**Post date:** [October 14, 2021, 12:41pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/10 "2021-10-14T12:41:12Z")

</div>

@JamilAhmed Currently we are not using micro gateway. We use other application(developed using native solace JCMS - sendRequest API) to read the reply from orchestrator now. Microgateway will replace this application later.

---

<div class="post-metadata">

**Author:** ![JamilAhmed](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/jamilahmed/32/78_2.png) [@JamilAhmed](https://community.solace.com/u/JamilAhmed)\
**Post date:** [October 14, 2021, 1:11pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/11 "2021-10-14T13:11:58Z")

</div>

OK let’s debug together what is going wrong. I’ll dm you to arrange.

---

<div class="post-metadata">

**Author:** ![marc](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/marc/32/2191_2.png) [@marc](https://community.solace.com/u/marc)\
**Post date:** [October 14, 2021, 3:19pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/12 "2021-10-14T15:19:33Z")

</div>

Thanks so much @JamilAhmed for jumping in to help out! definitely curious what you find the issue is

---

<div class="post-metadata">

**Author:** ![JamilAhmed](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/jamilahmed/32/78_2.png) [@JamilAhmed](https://community.solace.com/u/JamilAhmed)\
**Post date:** [October 15, 2021, 11:24am UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/13 "2021-10-15T11:24:08Z")

</div>

Hi @marc we confirmed through client statistics that request messages get sent out and a reply is coming back. (Counter increments for each attempts.)

With the original requestor sending a blocking request, it times out and doesn’t seem to detect the reply as having come back. We are planning to use the message dump feature of `sdkperf` to see both directions of the flow and check if all is correct and as expected in terms of correlation IDs and such. We’re picking up again Monday.

Will update this thread once resolved.

---

<div class="post-metadata">

**Author:** ![JamilAhmed](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/jamilahmed/32/78_2.png) [@JamilAhmed](https://community.solace.com/u/JamilAhmed)\
**Post date:** [October 18, 2021, 1:14pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/14 "2021-10-18T13:14:24Z")

</div>

Hi @marc, an update for the thread for those interested…

When an application using jcsmp is the requestor, and sends those requests with the blocking call, any reply messages sent using spring cloud stream will fail to correlate back and a timeout exception is thrown.

For [Requestor.request](https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/Requestor.html):

```auto
BytesXMLMessage request(XMLMessage request,
                        long timeoutMillis,
                        Destination sendDestination)
                 throws JCSMPException

```

> **Blocking mode**  
> The timeoutMillis parameter controls whether this call should operate in a blocking fashion.
> 
> If \>0, the call blocks for up to the number of milliseconds specified by timeoutMillis while the Requestor waits for a reply. If none is received during this time, a JCSMPRequestTimeoutException is thrown.
> 
> If 0, the call returns null after the request message has been sent. The application should then examine incoming messages on a XMLMessageConsumer or its XMLMessageListener for a reply, which will be sent to the Destination specified in the request’s ReplyTo header field. To correlate replies to sent requests, an application can use the CorrelationId field on outgoing requests.

The issue seems to be the reply messages coming back not having the `isReply` attribute set on them. If the application was using jcsmp, the [XMLProducer.sendReply](https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/XMLMessageProducer.html#sendReply-com.solacesystems.jcsmp.XMLMessage-com.solacesystems.jcsmp.XMLMessage-) call takes care of automatically setting this.

> Automatically copies requestMessage’s CorrelationId to replyMessage and sets the reply attribute on the latter. replyMessage is sent to the Destination returned by requestMessage.getReplyTo().

If sending that message without that convenience function, then you would have called this:  
[setAsReplyMessage(true)](https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/XMLMessage.html#setAsReplyMessage-boolean-)

The only way to make it work is to send the requests non-blocking, and then asychronously handle all the reply messages that arrive in `onReceive` and do correlation yourself using the value in `correlationID`.

Since the Solace Binder allows the reply-to destination for a message to be set using the special `solace_replyTo` [message header](https://github.com/SolaceProducts/solace-spring-cloud/tree/master/solace-spring-cloud-starters/solace-spring-cloud-stream-starter#solace-message-headers), there should be a way to allow the `isReply` attribute to be set on outbound messages too?

Perhaps a new `solace_setAsReply` header?

---

<div class="post-metadata">

**Author:** ![marc](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/marc/32/2191_2.png) [@marc](https://community.solace.com/u/marc)\
**Post date:** [October 20, 2021, 5:27pm UTC](https://community.solace.com/t/solace-replyto-header-is-failed-to-retrieve-in-spring-cloud-stream/957/15 "2021-10-20T17:27:00Z")

</div>

Thanks @JamilAhmed and @as63010 for chasing this down. I just wanted to provide an update as I spoke with the RND team our cloud stream binder yesterday. Your troubleshooting is correct that when using the JCSMP `Requestor.request` convenience function the replier must set a message attribute using the `setAsReplyMessage(true)` method in JCSMP (or similar methods in other SMF apis). My understanding is that this flag is basically used internally to the broker for enhanced performance when implementing the Req/Reply pattern between SMFs APIs. Unfortunately, the setting of this flag is not currently supported in the Solace Spring Cloud Stream binder.

So I’d say 3 things here:

1. We are going to add support for this in the next release of the Spring Cloud Stream binder. We are planning quite a few things as part of that release and it is being scoped/planned now. With the holiday coming up it is likely that the release w/ this feature will be early in calendar year 2022.
2. Until that feature is added to the Spring Cloud Stream binder, if you are trying to do Req/Reply with JCSMP as the Requestor and Spring Cloud Stream as the Replier you will need to avoid using the JCSMP `Requestor.request` convenience function and just implement the requestor messaging logic with base JCSMP (set ReplyTo & ApplicationMessageId/CorrelationID headers, listen on the ReplyTo topic, correlate response)
3. Of course you could also write a replier using a different SMF API, but I also want to note that it is currently supported via our JMS API and if you (or anyone else that finds this thread) decide to use JMS as the replier this property can be set using [SupportedProperty.Solace\_JMS\_Prop\_IS\_Reply\_Message](https://docs.solace.com/API-Developer-Online-Ref-Documentation/jms/com/solacesystems/jms/SupportedProperty.html#SOLACE_JMS_PROP_IS_REPLY_MESSAGE)

Hope that helps!
