Does spring cloud contract supports callback response imitation? - java

I dont mean supporting async responses (like described here https://cloud.spring.io/spring-cloud-contract/reference/html/project-features.html#contract-dsl-async).
I mean situation when after my request I get response synchronously. And after that I want to get some request back from stub. Smth like this:
request from my service to stub:
POST /subscription {subscription params...}
synchronous response from stub:
202 Accepted
after a while request from stub to my service:
POST /subscription-answer {subscription with more params...}

Related

Clearing MDC when HTTP response is sent by Jersey

I'm building a Java back-end using Spring with Jersey, where I want to send a multipart response to the client.
I have a GET call that looks something like this:
#Path("/status/{requestID}")
#GET
public Response getStatus(#PathParam("requestID") String requestId) {
MDC.put("myRequestID", requestId);
// Do some processing
return response;
}
I use MDC to add request ID and other information that I need in my logs. Now the response that I create is Multipart, and since Jersey internally converts this Multipart response to HTTP response, during this processing I have certain callbacks which logs messages and I want the MDC to be populated at that time, with whatever was put in my getStatus call.
Now, usually I would call MDC.clear() before returning status in my getStatus call. But, now that I want to wait for Jersey to complete processing, I cannot do that.
Is there any callback that Jersey provides once the HTTP response processing is complete, where I can do this cleanup?

Synchronous Facade For Asynchronous Request-Response

Context
I am receiving a sync request from an external client to my spring boot rest endpoint(/request)
My rest service makes a sync call to Microservice A
After A is finished executing it publishes an event & then returns a response to my rest client
The event published by A is being consumed by another microservice B which performs some transaction and sends a response to the restClient endpoint /success indicating a success response
Problem
How do I make my /request endpoint wait until /success has been hit before returning a response to the client.
Use Semaphore for your desired endpoint and acquire() when needed.
https://www.geeksforgeeks.org/semaphore-in-java/

Change the endpoint method at handle request interceptor

I am working soap service using spring WS , I want the endpoint need to changed at handle request method in endpoint interceptor based on some condition. Is it possible to change endpoint method at handle request method ?

How do we perform POST operation using publish and subscribe in JMS for asynchronous calls?

Consider the endpoint as "abc" and method as "POST".
I need JSON request and response using Publish/Subscribe in JMS for asynchronous call.

spring http outbound gateway customization

My requirement is to call siebel soap webservice, In the process handle request and response on a same method call, so that I can add token to the request header from the apache common pool and once get the response with token, grab the token from response and send it to pool. Here I have mechanism to verify old token too,
I need request token and response token on same class.
Future planning to add retry mechanism.
Currently I am using SI Http outbound gateway.
Any thoughts, appreciate it.
Thanks
So, what you need is named pre- and post-process. Not sure why you don't use Spring Integration WS support for calling that Siegel service, but even with the HTTP you can get a gain via Interceptor abstraction.
What I mean that you can inject RestTemplate into HTTP Outbound Gateway supplied with the ClientHttpRequestInterceptor implementation to provide a desired logic.
If you'd use WS Outbound Gateway, you could do that in the similar ClientInterceptor abstraction.
Of course, you can achieve that via HeaderMapper implementation, but that has different responsibility...
I found the way to achieve this,
Created a class to extends HttpRequestExecutingMessageHandler than overrided handleRequestMessage()
http://docs.spring.io/spring-integration/reference/html/http.html#http-outbound

Categories

Resources