From: Kai Moritz Date: Sun, 20 Jun 2021 17:51:13 +0000 (+0200) Subject: Switched from single-node (assign) to multi-instance (subscribe) X-Git-Url: https://juplo.de/gitweb/?a=commitdiff_plain;h=43ea59755f9673864a3ef95250009f091e99a760;hp=43ea59755f9673864a3ef95250009f091e99a760;p=demos%2Fkafka%2Fdemos-kafka-payment-system-transfer Switched from single-node (assign) to multi-instance (subscribe) * TransferConsumer uses subscribe() instead of assign(). * The subscription happens during the instanciation of TransferConsumer. * The restorage-process of the state happens in onPartitionsAssigned(). * To be able to reset all data, that belongs to a specific partition after a rebalance, in order to avoid state errors because of handling events several times, InMemoryTransferRepository must know, which partition a transfer belongs to. * To achieve this, the partitioning algorithm is made known explicitly. * On each rebalance, a mapping from the partions to the currently assigned instances is maintained. * TransferController uses the explicitly known partitioning algorithm, to look up the partion for a requested transfer and decide, if the data is available locally. * If not, it looks up the assigned instance in the maintained mapping and redirects the request. ---