If you’re an OpenFin developer, you probably prefer to use REST for remote API calls whenever possible. This works great for query-response type requests, but has its limits beyond that, specifically:
All of these limitations can be overcome by coupling REST with a multi-protocol message broker that natively supports web-based protocols. Your apps can still use web-friendly API management, and the broker handles service reliability issues, publish/subscribe and queueing semantics, and access to non-web legacy systems.
Let’s take a look at three common scenarios and how OpenFin REST interactions can be improved with a message broker acting as an intermediary.
This is the pattern where REST is most straightforward. You simply POST (or PUT) and specify whether you want the interaction to be synchronous or asynchronous.
I know what you’re thinking:
They both do the same thing, only the first one is simpler! Why add Solace?!?”
There are three primary reasons people put a message broker between their REST POSTs and their RESTful services:
REST may be all you need if everything is a service lookup and everything is working, but distributed systems get messy, and a broker improves both reliability and governance.
Scenario 2 is still a point-to-point interaction, but this time the remote service does not offer a RESTful interface. We’ve discussed the architectural choices facing this scenario in detail in the whitepaper A Guide to Connectivity for OpenFin Architects and Developers. This time Solace is acting as a protocol and security bridge, terminating the REST request, forwarding the payload to a messaging queue or topic, and doing the same with the responses.
The means of receiving the response will vary depending on the nature of your REST request. If the request is synchronous, Solace will hold the connection open until the associated messaging interaction has completed. If the REST POST is asynchronous, you’ll need a means of receiving the message via callback, or polling for the results. There’s a companion blog post entitled Handling OpenFin Inbound Events from the Hybrid Cloud that covers handling message flow in the other direction.
In scenario 3, the client application needs to post information to multiple remote services. Without a broker, the only way to do this is to have the application send the message to each application one by one, or write some kind of intermediary that forwards the message inside a RESTful service.
Solace offers an elegant solution to this by allowing you to use REST to POST the data along with a publishing topic as metadata. Remote services identify themselves as subscribers and PubSub+ publishes onto many different messaging networks on the specified topic. The net effect is that your OpenFin apps use REST and the data automatically goes to all the subscribers, wherever they are. Some subscribers may produce a response, and others may simply listen, for example for logging or archival.
Of course, many applications will want to include exchange patterns that accomplish all three of these scenarios. The all-of-the-above scenario highlights the governance and reliability advantages of using a broker.
If an application needed to use all of the message patterns we have discussed in this blog post, without a message broker, it would need to vary the use of REST, possibly handle security differently for each pattern, and deal with all failure scenarios. With a message broker, it simply POSTs the data to Solace which acts as a security and traffic intermediary, routing to all data sources.
Note: To keep the image above from overcrowding, I did not show the return messages. They would work the same as they did in the prior scenario diagrams above.
So there you have it, REST is awesome because it’s so simple—but it has some serious limitations. If operationalizing systems for predictability and high-availability, accessing legacy systems, or taking advantage of messaging-like semantics are requirements for your apps, consider adding a multi-protocol broker to bridge REST into other protocols and bolster your system’s resilience.
Be sure to check out the companion post that discusses receiving notifications and responses from asynchronous REST requests: Handling OpenFin Inbound Events from the Hybrid Cloud.
Thomas Kunnumpurath is the vice president of systems engineering, Americas at Solace. He enjoys evangelizing the benefits of using Solace to supercharge digital transformation to customers ranging in industries from capital markets to the United States Army.[position] => [url] => https://solace.com/blog/author/thomaskunnumpurath/ ) )