Pub/Sub - Whole Body, Or Just Notification

I have a EXIF Meta Data Service, after it has succesfully parsed and stored the EXIF Data what should be the contents of its published message?

A) Should it be the full EXIF Data, So any other service intrested can pick its relevent infomation

Or

B) Should it be a "nofication" saying new data is avaliable and if you want it then come and call for it.

---

Option A seems the easiest, and will not cause the service to publish and then been inundated by requests. But it feels dirty sending the whole EXIF Payload for a service only intrested in the taken date!

Option B gives us the ability to stand up specific endpoints with Limited data sets, Only want Geo Coords? you got it!

I Guess I could have an Option C, Which sends a limited amount of data any if anymore is needed then it can be called for??

​

Love to hear your views! I Would google for it, but not 100% of terms i'd use..

Posted Sep 14, 2020, 11:32 AM UTC

44
beardedlady426283•

I think the reason for going with B would be traceability and probably simplified debugging. Like if you are writing json payloads to S3 and the providing the URL to the item in the notification, you can always look back at historic payloads if you need to, or recover past data.

If it's all in the message, you might risk losing that to a max-age time out on the message service.

It's probably something where you can start with A as it has fewer moving parts, and then move to B with very little pain if you find the need, and enrich you messages for C if you find that use case as well.

2
yolex•

Dunno if I understood the question 100%, but I think it depends on who is listening. In my experience with pub/sub systems, you should publish whatever changed so all downstream apps/services have the most up to date version with the least amount of data transferred.

So if there is a new entry you return everything as a snapshot. If there is an update you publish the delta between the snapshot and whatever changed.

The notification idea doesn't sound great unless the data is not that interesting, but surely whoever made the request is interested on the latest up to date persisted version of the data.

2
GenericDevOP•

So in the case of this service. It parses a photo for EXIF data. And the services intrest we might be .... a geo service which wants to enhance the exif with landmarks near the geo coordinates, and a sorting service which sorts the photos based on taken date. And a tagging service which only cares about the male and model of the camera..

Each service only cares about its own data. Bit for all services to fulfilled I would have to provide all this information in one message to all services..

Alternative I could just say “I have new exif data for photo 1233323211” and each of the 3 services could call into the EXIF service for the information they require...

3
yolex•

I get it better now. In that case a notification does make some more sense, but maybe in the sense of "I have new geo data for photo 123123", so then only the geo service asks for it and you don't flood the network (but again this depends on how much flooded you want your network to be. You could have different reqs, where traffic is not that big of a deal). However, in that case if your service gets expanded a bit, then you might need a code change to make sure the extra data you want get requested depending on the notification.

I might be a bit biased, but I think sending deltas would be the easiest. The consuming service would then select whether this is data it wants and if not discard it, plus it saves you an extra call.

2