Closed I320857 closed 4 months ago
First of all, please note that the 404 you are receiving is the result of an individual item within the batch, not the overall batch request. So "only" some part of the batch failed. It seems likely that one of your requests inside the batch is referencing some entity or object that the server can't find, thus returning a 404
for that particular change set. Please double check the IDs you are using and how you are building the requests.
Finally, if you do believe your requests are correct please get in contact with the maintainers of the OData service and share with them the exact batch request body (which you can get via request.getBatchRequestBody()
).
Some further remarks:
Overall, your code seems overly complex. I'd recommend reducing it down to the simplest possible case, removing all threading and only adding it back in, if you actually do want to run things in parallel. And if you do, using simply Future runningTask = ThreadContextExecutors.submit(myTask);
should suffice (see the docs).
Hi Matthias,
Added few clarifications on certain decisions:
Is there any particular reason you are building these requests manually with the low-level API, and not using a generated client? We went with low-level API as the metadata of S/4 Odata can keep changing and we would have had to update our resource folder regularly on every change. Also, S/4 release will be different than ours and in case of breaking changes in API, it can cause downtime for our users in BTP.
Thanks and Regards, Sandesh
Issue Description
Application Background: CPR is a Web application built using CAP Java framework and running on BTP Cloud foundry environment. We use Price Calculation API from S/4 On-Prem to calculate prices in CPR.
Use Case Currently at CPR item level, there are 3 price fields. As part of new use case, we need to recalculate these prices whenever date is changed in CPR. So, we have created 3 Future tasks in After Save handler. Each of these tasks, will create a batch request using Generic Odata client with POST request headers for all items to fetch price responses for specific price field.
To avoid, HTTP Client Caching issue in Multi-Threading scenarios, we are waiting for each task to complete before submitting next task using separate executor service. Also, we have provided executor service 15 minutes of time to finish the tasks.
Issue When we have only 1 item with 3 prices to be calculated in 3 separate tasks, batch response is received for all 3 tasks. If we have 10 items with only 2 prices to be calculated using 2 separate tasks, batch response is received for all 2 tasks. But If we have 10 items with only 3 prices to be calculated using 3 separate tasks, the scenario is failing with 404 status code.
I have attached the logs. You can see the exception at the end. It has processed the first task response and at the second task response processing, it fails with error: com.sap.cloud.sdk.datamodel.odata.client.exception.ODataServiceErrorException: The HTTP response code (404) indicates an error. The OData service responded with an error message.
Code
Impact / Priority
We need to finish this task by July 12 as this will be our dev close for the upcoming Q3 release. This feature is of high prio for our release.
Error Message
service logs.txt
Maven Dependency Tree
Project Details
This is provided above.
Checklist