Hi Team
I followed this tutorial and it seems it is possible to route a request to a REST backend via Solace
Publish / Subscribe
These tutorials get you up to speed sending and receiving messages with Solace technology. 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.
How to use Solace PubSub+ Event Broker and Postman for RESTful Request/Reply - Solace
Postman is perhaps the most popular tool for quickly bootstrapping RESTful interactions. Since Solace PubSub+ Software Event Broker natively supports several protocols including HTTP, it makes sense to use Postman to explore some of what PubSub+ Event Broker offers.
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.
Thanks
Susi
Hi @Susi_Dman …! Yup, all you have to do is populate the Solace-Reply-To-Destination > in your request message, and you should get the response routed back to the topic or queue that you specify.
Format:
Solace-Reply-To-Destination: /(QUEUE |TOPIC)/<destination_string>
See this page for more info: Solace REST HTTP Message Encoding
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: REST
Hope that helps!
Hi Aaron
Many thanks for pointing out the REST Gateway option. I was able to give a try with this blog post
Event-Enable your REST Architecture with Solace PubSub+, Part 1
Negative : Note: this tutorial assumes that you are using the default Message VPN on the software broker. If not (e.g. hardware appliance, Solace Cloud, or just a different VPN), ensure you substitute the proper VPN name, username, etc. as you progress through this tutorial. 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://.messaging.solace.cloud:9443/hr/* → https://my.hr.backend/*
https://.messaging.solace.cloud:9443/payroll/* → https://my.payroll.com///*
Thanks
Susi
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-Destination in 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).
Hi Aaron
Thanks for your response.
For the time being, I managed to do it with Gateway. Followed a couple of your articles and videos, which are very informative.
Thanks again
Susi
Hi Aron
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.
Thanks
Susi