Ok, so you’re hoping that you could build a response topic that contains “ok” or “error” or something in the topic, eh? And then filter based on that…?
But (if I read you correctly) what you’re really trying to do is filter on the response somehow. Obviously, if you could use Solace hierarchical topics directly, you’d embed something in the topic, but what other options are there? Another option which might work for an existing REST flow is took look at the HTTP response code. The backend REST service will/should pass along a response code, right? 200 OK, or 40x for something bad? HTTP codes are passed through the broker as User Properties on the message. And while we can’t do topic filtering on that, you could use a Selector to look for certain error codes? This might actually be one of the good uses of a Topic Endpoint in Solace, because it performs its Selector on ingress, rather than a Queue which stores all messages, and performs Selectors on egress based on a client.
… goes and tries …
So yes, you can definitely do this! I made a Topic Endpoint “te1
”, and then used a Solace client (SdkPerf in my case) to connect a client to that TE and specify a subscription (as you had above: #P2P/v:*/#rest-*/POST/>
for all POST responses) (maybe use the specific topic rather than >
to be more selective) as well as a Selector JMS_Solace_HTTP_status_code>299
.
BTW, I tested this using SdkPerf C and a Topic Endpoint called te-rest-errors
:
./sdkperf_c -cip=localhost -sdl=te-rest-errors -stl="#P2P/v:*/#rest-*/>" -ssl="JMS_Solace_HTTP_status_code>299" -md
And then (after having configured the VPN for MicroGateway and RDP to a backend service – SEMP in my case) I got this on the command line when issuing a bad request:
^^^^^^^^^^^^^^^^^^ Start Message ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Destination: Topic '#P2P/v:cd6c1f921db8/#rest-06c7bdc3dedfb2c5/GET/SEMP/v2/config/msgVpns'
ApplicationMessageId: ID:Solace-c6e9493cdae8b1ed
CorrelationId: ID:Solace-c6e9493cdae8b1ed
HTTP Content Type: application/json
Class Of Service: COS_1
DeliveryMode: NON-PERSISTENT
Message Id: 3
Reply Message
User Property Map:
Key 'JMS_Solace_HTTP_field_Date' (STRING) Tue, 27 Apr 2021 06:41:26 GMT
Key 'JMS_Solace_HTTP_field_Server' (STRING) Solace_VMR/9.2.0.14
Key 'JMS_Solace_HTTP_field_Cache-Control' (STRING) no-cache
Key 'JMS_Solace_HTTP_field_WWW-Authenticate' (STRING) Basic realm="Unauthorized"
Key 'JMS_Solace_HTTP_field_Access-Control-Allow-Credentials' (STRING) true
Key 'JMS_Solace_HTTP_field_Access-Control-Allow-Headers' (STRING) Authorization, Content-Type, X-Requested-With
Key 'JMS_Solace_HTTP_field_Access-Control-Allow-Methods' (STRING) GET, POST, PUT, PATCH, DELETE, OPTIONS
Key 'JMS_Solace_HTTP_field_Strict-Transport-Security' (STRING) max-age=31536000
Key 'JMS_Solace_HTTP_status_code' (UINT16) 401
Key 'JMS_Solace_HTTP_reason_phrase' (STRING) Unauthorized
Binary Attachment String: len=318
<SNIP>
So if you really wanted to, you could Selector on ANY of those User Properties that get populated by the MicroGateway!
Nice. I like this.