REST Producers
Sending messages to a Solace PubSub+ event broker is accomplished with a REST publishing client. A REST publishing client is authenticated when a connection is established. In general, it is recommended that applications use HTTP 1.1 persistent connections to allow for higher performance sending by avoiding the need to establish a connection for each message send action.
One-way POST to Solace
When the application sends a message and no reply is expected, producers send an HTTP POST request containing all the relevant message headers, properties, and contents. The Solace PubSub+ event broker converts this message to the internal Solace Message Format (SMF) for routing and sends back an HTTP 200 OK response when the message is successfully accepted by the event broker. For persistent messages, the 200 OK is returned after the message has been successfully stored on the event broker.
The format of the REST POST request is outlined in Solace REST HTTP Message Encoding.
Request / Reply to Solace
When an application sends a request and expects a reply, the Solace REST messaging provides two options:
- A blocking exchange where the Solace PubSub+ event broker correlates the request and reply together for the application.
- An asynchronous exchange, and the reply is received later.
Synchronous Request / Reply
In the synchronous case, when the Solace PubSub+ event broker receives the HTTP POST request, it delays returning the HTTP response. This allows the event broker to send the request out on the Solace message bus, waiting for a reply to be received before responding to the REST consumer. When a reply is received or the request times out, the event broker responds to the REST producer. This exchange is shown in the following figure.
The body of the HTTP response carries the contents of the response, as outlined in Solace REST HTTP Message Encoding.
Asynchronous Request / Reply
The Solace REST messaging feature also provides publishers the option of specifying a destination for replies. In this way, REST applications can send a message to a Solace PubSub+ event broker and receive a reply later using the specified reply-to destination. This exchange is shown in the following figure.
With asynchronous request/reply, the REST application is both a REST producer and a REST consumer. The request is published to the event broker normally, and the REST producer receives the 200 OK when the event broker accepts the message. When the JMS application sends the reply, the event broker sends the reply to the REST application on a separate HTTP connection as a new HTTP POST request. The REST application responds with a final 200 OK response to acknowledge receipt of the reply.
The REST application can specify a correlation ID in the message to correlate the request with the response that is received asynchronously.