0
votes

I need to POST a JSON structure to a REST endpoint and process the data it returns (all of this is with JSON).

I am planning to use a HTTP outbound gateway for this purpose. Now the thing is that after I have transformed my object (payload of the message) into a JSON format and before I transmit it to the endpoint the payload should be dropped into a database so that in case the endpoint is not available the call can be retried.

As I want to a) set the status accordingly after the call`
b) update the respective row with a uuid from the REST endpoint

I need to somehow relate the uuid from my object (the business key) as part of the outbound message to the response of the REST endpoint that is placed on the reply channel. As I cannot ask the provider to return my uuid as part of the response how can I achieve this purely on the client side?

1
Can you store it in a message header? AFAIK the outbound gateway copies the headers from the message placed on the request-channel to the message placed on the reply-channel. Or is there some reason you don't want to use headers?petebowden

1 Answers

0
votes

You can add a custom advice to the outbound endpoint using the request-handler-advice-chain. Simply subclass AbstractRequestHandlerAdvice. It's effectively an 'around' advice so you can store it in the DB before invoking the handler and update the status afterwards.

See 'Adding Behavior to Endpoints'

and specifically 'Custom Advice Classes'