I solved it using custom call back (overriding Callback of retrofit). In this class pass retry count. So on response success or failure you will have access to variable retry count which will be web service specific. So will not interfere each other in case of parallel execution.
@POST("/xyz/abc/")
void getSomeData(
@Body TypedInput body,
Callback<Response> callback);
You can create and pass your custom callback and save some object/int value to uniquely identify request.
public interface CustomOnRequestFinishedListener {
void onSuccess(Object response, Response retrofitResponse, Object data);
void onError(RetrofitError error, Object data);
}
Implement CustomOnRequestFinishedListener where you want to call CustomCallback and will get success/failure callback
public class CustomCallback extends CallBack
{
private final Object data;
private final CustomOnRequestFinishedListener customOnRequestFinishedListener;
public CustomCallback(CustomOnRequestFinishedListener customOnRequestFinishedListener, Object data)
{
this.data = data;
this.customOnRequestFinishedListener = customOnRequestFinishedListener;
}
@Override
public void success(Object o, Response response)
{
customOnRequestFinishedListener.onSuccess(o, response, data);
}
@Override
public void failure(RetrofitError error)
{
customOnRequestFinishedListener.onError(error, data);
}
}
By this way you will initially setting some unique data in request and will get same data in response.