That’s similar to what I did, but I have issues in the integration tests where I run the whole flink job using mock source and sink. In that scenario, there’s no way of enforcing the order of the message consumption.
I have a CoProcessFunction, which receives the messages from Source1, buffers them in a state. When a message from Source2 comes, it does the business logic and outputs the message to the collector.
In the tests, sometimes Source2 is processed first. I could implement flags to check if both streams were processed and only then collect to the output, but I wanted to avoid it.