routing mode determines which internal topic a message should be published to so this is a producer on a partition topic that exists there right so this part this topic has in this case five partitions P0 through four they're assigned to different Brokers randomly right you can have uh and it's perfectly valid to have multiple partitions spread across you know on the same broker less Brokers and partitions it just is what it is they have to be served somewhere now internally as we mentioned when you first create this producer it creates a separate uh private producer
underneath the covers and it manages it for you it's transparent to you and your routing mode when you send the message ends up dumping it into the internal queue of these uh under you know underneath the covers producers and eventually they're going to send this information over and the client handles creating all these connections multiplexing it over sending sending the data together and they get this information you know back and forth right so you're sending the data between the two uh here the routing mode again determines where it's going to go right so on the
consumer side a similar thing occurs if you create a consumer on a partition topic then the underneath the covers it knows it gets the metadata doesn't look up and says hey this is a partition topic I have five partitions so it creates these separate five different consumers and it does the same functions of pulling the data from each of these partitions and then delivering that information to the internal uh to its internal cues on each one of these and when the consumer goes through that information it it pulls that information back in the subscription mode
determines which consumers a message you know should be delivered to and consumed from right so it guarantees again like an exclusive ordering subscription type on a on a partition topic we'll guarantee the ordering still uh message ordering because it knows you can go look at all these uh metadata across all these messages in the internal queue and pick the one with you know the the lower the the most recent time and then pick the next one the next one and so on and so forth and so based on what your subscription mode is these messages
come back to the consumers and that's all handled for you uh transparently so with Partition topics there's no code changes but there are settings that matter right and so if you add additional partitions your broker is going to discover the partition uh under on the up auto update partitions interval setting here at the bottom which determines talk and it checks for updated partition count so by default every minute they're going to check to see if there's any messages with new partitions now if the if you have multiple producers and they are all producing data this
is not going to happen automatically uh you know it won't happen at the same time this is going to be a period of time between when they discover that the new inner that the new interval and the ordering is going to change and depending on what your needs are around ordering if you want to scale up you may want to pause your producers and then scale up to get a clean cut over point right that's the key if this doesn't solve the issues for your consumers because key one was on partition two has moved to
partition three so you still have to deal with this on your consumer side but you have a clean cut over on your production side so you can deal with consumers with a custom mechanism and this only matters if you care about the order otherwise it isn't a concern right so only if you're using uh like an exclusive type and you're guaranteed about the message ordering then it's best to have a clear cutoff point uh and your consumer has to be aware of that and you know sample the data do some Reservoir sampling on the data
on the consumer side and then reorder it make such a way that it's guaranteed because you've added a partition and broken the order order and guarantee on that existing topic now two other settings are these Max cunning messages across partitions uh and this determines like your total outstanding uh number of messages you can have sitting in your internal buffers inside those producers right so remember if you go back to that picture here right so you're under the covers you have five producers so each one of these can have so this is saying across all the
outstanding messages to be sent across these guys are internal cues uh can't be greater than this particular number that's set in this case 50 000 right so this is your max pending messages out there in terms of any messages this could be pending at that point in time as well and that'll trigger a flush of all those simultaneously so for some reason if you want to have really large two sizes this is that you have you know or you have a large number of partitions uh then that's that's kind of it and the max size
is 50 000 which is you know 50 times the default buffer size that really comes into into play but if you have more than 50 partitions that might that might come into play and as we talked about in the code examples the message routing mode by default we've already discussed the default is around Robin uh once again this is only if you set don't set a key and you can override that override that behavior as well