Search code examples
javaspringweb-serviceshttpservice

JAVA: Store request and response messages (XML or JSON) in database for Webservice or HTTP calls


I want to store raw request and responses (XMLs or JSON) in database for Wbservices and HTTP calls in a Java Web application. How do I achieve this without degrading performance of the services.

I have seen few implementations like -

  • Asynchronously using IBM Workmanager (com.ibm.websphere.asynchbeans.WorkManager). This will do the job in a separate thread - I can't use this as this is more specific to IBM Websphere application server
  • Using Spring AOP - Apparently its more complex and as per my understanding Spring will not create a separate thread and may degrade performance.

Is there any other way (better way) of implementing this? Any other third party library which does the same work as above mentioned IBM Workmanager? Any suggestion is most appreciated.


Solution

  • You can pass your request and response to a method annotated with Spring's @Async: Creating Asynchronous Methods