Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best practise concerning topic names

What is the best practise concerning the topic name using google-pubsub.

If I have theses events :

  • customer email updated
  • customer address updated
  • customer created
  • customer deleted
  • article created
  • article deleted ...

What is the best practise concerning topic names :

  • create a customer topic and an article topic containing each one the events of its domain
  • create a deleted topic that will contains customer deleted and article deleted, etc ..
  • create a topic by event customer:created, customer:deleted, etc ...

Or an other ..

like image 286
Julien TASSIN Avatar asked Apr 11 '19 16:04

Julien TASSIN


People also ask

Are Kafka topic names case sensitive?

Kafka topic names are case-sensitive.

Why are naming conventions important?

Naming conventions make sure users know how to name digital assets so that filenames or titles are consistent and contain all the right information. They help you store and organise your files. Without them, your asset library can become chaotic and make it much harder to find images when you need them.

Can we rename a Kafka topic?

topicName has changed. No translations currently exist.


1 Answers

The decision one would make on topics really depends on the use case. If your entire system architecture has a clear delineation across customer/article or across created/updated/deleted, then it could make sense to split the topics along those same lines. If not, then there may be less use in splitting into multiple topics.

One way to determine how to do the split could be to consider the type of each message. If you split across all these topics, would they all have the same type of message (maybe an "event" message) or are the message types going to be different? If they are different, then different topics may make sense.

Most interesting might be the behavior on the subscribe side. Will the same subscriber be interested in events for both customers and articles or are their different subscribers for each? What about create/delete/update? A split along these lines sounds less likely. If all subscribers are going to be interested in all messages, then a single topic is probably reasonable. Otherwise, a subscriber will have to receive messages from multiple subscriptions. If some subscribers are interested in a subset of messages, then separate topics (and therefore, separate subscriptions) could be beneficial. Otherwise, the subscribers will have to look at all messages and immediately ack the messages they are not interested in, since Google Cloud Pub/Sub does not support filtering at this time. If it is a mix, then it is a tradeoff between more complexity in the subscriber interested in all messages (using different topics) and complexity in the subscriber interested in a subset (using the same topic and having to filter).

like image 65
Kamal Aboul-Hosn Avatar answered Oct 14 '22 07:10

Kamal Aboul-Hosn