LONDON—Coffee traders are scrambling to redirect shipments headed for Russia and Ukraine as trade flows to the two countries collapse due to Western sanctions imposed on Moscow and Kyiv’s move to close its ports. Russia is the world’s fourth-largest coffee importer after the European Union, the United States, and Japan. “(Trade flows) are grinding to a halt. Realistically these contracts will have to be voided. It’s as simple as that,” said a Geneva-based coffee trader at a major international firm. Russia and Ukraine combined account for nearly 4 percent of global coffee consumption. The two countries largely import robusta coffee beans, which are often used to make instant coffee. The beans are a cheaper alternative to smoother-tasting arabica. The world’s biggest container shipping lines, including the top three—MSC, Maersk, and CMA CGM—have temporarily suspended cargo shipments to and from Russia, while Ukraine’s ports have been closed since Russia invaded. “Some …