0

I'm trying to do an inclusion between Resources that are handled by different services. Both services use Katharsis. Let's assume those resources are Book and Publisher. I want to be able to include a publisher when GETing a book resource.

I know I could have the Book service do an HTTP call to the Publisher service. The issue here is that I'd get a JSON representation of the Publisher. I'd have to deserialize it into a Publisher POJO and put in in the Book POJO. Then Katharsis would serialize the whole thing again w/ the included Publisher.

One problem is the Book service would need to have knowledge of the Publisher model and its relationships etc. I suppose I could extract the model from the publisher service into a java api, and include it into the book service. Not sure it's a good practice though.

Another problem relates to the efficiency. I'm deserializing only to serialize again.

Is there a better way? How do people handle this?

user2793390
  • 741
  • 7
  • 29
  • is there something wrong with returning a relationship to the Resource Identifier for the requested resource (i.e. full Book resource with relationship to a Publisher Resource Identifier)? You could defer the inefficiency of including the entire Publisher to times where it's explicitly requested with the `include` query param – jdubjdub Nov 10 '17 at 22:15
  • @jdubjdub my question is about the times when include is explicitly requested. Is there something better than what I came up with? – user2793390 Nov 13 '17 at 17:47
  • Sounds like you sort of need to take the hit on performance here... maybe could try to do some caching so you don't need to make too many requests if this stuff doesn't change that often. – jdubjdub Nov 13 '17 at 19:02

0 Answers0