The problem is this limit is specific to Service A. All other services that depend on DB do not need this limit.
Solution P: Abstract wayaway the problem
Resource r = service.fetchResource();
Don't expect using code to deal with your little problems. Don't even ask it to know what it's talking to.
Classclass ServiceA implements Service {
public Resource FetchResource(...) {
if (numberOfRoundTrips > ServiceDefinedLimit) {
throw new Exception("Resource is too large");
}
return DB.resource("A");
}
}
Don't expect other services to know anything about your weird problems either.
Classclass ServiceB implements Service {
public Resource FetchResource(...) {
//what round trips?
return DB.resource("B");
}
}