I would like to route dynamically the different elements of a PCollection to different PubSub topics, based on the content of a field. The topics are not persistent but it is assumed that they exist when PubSubIO.Write() is executed at runtime. So Dataflow should only infer their names at runtime on a per-message basis.
The feature exists for BigQuery and dynamic table names : https://beam.apache.org/documentation/sdks/javadoc/2.0.0/org/apache/beam/sdk/io/gcp/bigquery/DynamicDestinations.html
Is there a way to do something similar with PubSubIO ?
Maybe not based on the message content but on an attribute ? https://beam.apache.org/documentation/sdks/javadoc/0.6.0/org/apache/beam/sdk/io/PubsubIO.PubsubMessage.html#getAttribute-java.lang.String-