Can I implemengt REST request/reply mechanism using Rest Delivery Points
I followed this tutorial and it seems it is possible to route a request to a REST backend via Solace
Is there any way that the response from the backend REST service can be routed back to the API client who invokes the solace REST endpoint?
This blog discusses a similar system, but in this case, the backend is JMS listener.
My requirement is to implement API proxy kind of solution where I can log all api requests/responses to a database using solace in between or any other means. I'm looking for a solution with minimal changes for the existing rest backends or introducing minimal services.
Hi @Susi Dman ..! Yup, all you have to do is populate the
Solace-Reply-To-Destinationin your request message, and you should get the response routed back to the topic or queue that you specify.
Solace-Reply-To-Destination: /(QUEUE |TOPIC)/<destination_string>
See this page for more info: https://docs.solace.com/API/RESTMessagingPrtl/Solace-REST-Message-Encoding.htm
Alternatively, you could explore using the REST Gateway mode (instead of REST Messaging mode), where the broker acts completely as a proxy, and will accept a variety of REST verbs (GET, PATCH, DELETE, etc.) instead of just the POST of the REST Messaging API. See here for more: https://docs.solace.com/API/REST/REST-get-start.htm#When
Hope that helps!0
Many thanks for pointing out the REST Gateway option. I was able to give a try with this blog post
I have a requirement that I want to proxy 2 backends with different context paths. Does something like URL-rewrite is possible with REST Gateway, if so where to configure it? For example, I want to achieve something like below
https://<myconn>.messaging.solace.cloud:9443/hr/* --> https://my.hr.backend/*
https://<myconn>.messaging.solace.cloud:9443/payroll/* --> https://my.payroll.com/<some>/<path>/*
Ok... if you use the Gateway mode, the URL is passed through exactly as is... you can't rewrite it. That is only possible with REST Messaging mode. In Gateway, if you just want the URL to remain the same, then that's what it does... the broker acts as a proxy.
So if you want to do some target rewriting, you'll want to use Messaging mode, have 2 RDPs, and then inside your two RDPs' queue bindings you can configure a custom target. Your first queue would be listening to
hr/>and your second RDP queue would be listening to
payrole/>. Then each inside the queue binding of each RDP you could specify your custom path for the downstream REST server.
And remember that your REST publisher will need to insert that header that I was talking about:
Solace-Reply-To-Destinationin order for the backend response to get routed back to the publisher.
Take a look at this video I made which shows some of what I'm talking about substitution expressions for the downstream target: https://youtu.be/INMrSL2fA3E?t=439 (don't worry that the video is for S3, doesn't really matter).1
I managed to get the reply back to the REST client using the 'Solace-Reply-Wait-Time-In-ms' header, but it isn't working 'Solace-Reply-To-Destination' header, I'm not sure what to use as the header value here, I tried with the same topic name (as published), and using the same queue name, but none of those worked.
My setup is as follows, Postman --> (send to https://my-solace-host:9443/TOPIC/java ) --> JavaApp
Where JavaApp is listening to a queue called 'q_java' and this has a TOPIC subscription to the topic 'java'
Any advice on this is appreciated.
Also If I want to replace the above JavaApp with Boomi (should I use Solace PubSub Partner connector or a Jms connector )? I tried using the Solace connector but could not get the reply back to Postman using 'Solace-Reply-Wait-Time-In-ms' header which works for Java.