public static Write<PubsubMessage> writeMessagesDynamic() {
    return Write.newBuilder()
        .setTopicProvider(null)
        .setTopicFunction(null)
        .setDynamicDestinations(true)
        .build();
  }
@Test
  public void testBigMessageBounded() throws IOException {
    String bigMsg =
        IntStream.range(0, 100_000).mapToObj(_unused -> "x").collect(Collectors.joining(""));

    OutgoingMessage msg =
        OutgoingMessage.of(
            com.google.pubsub.v1.PubsubMessage.newBuilder()
                .setData(ByteString.copyFromUtf8(bigMsg))
                .build(),
            0,
            null,
            "projects/project/topics/topic1");

    try (PubsubTestClientFactory factory =
        PubsubTestClient.createFactoryForPublish(null, ImmutableList.of(msg), ImmutableList.of())) {
      TimestampedValue<PubsubMessage> pubsubMsg =
          TimestampedValue.of(
              new PubsubMessage(
                      msg.getMessage().getData().toByteArray(),
                      Collections.emptyMap(),
                      msg.recordId())
                  .withTopic(msg.topic()),
              Instant.ofEpochMilli(msg.getTimestampMsSinceEpoch()));

      PCollection<PubsubMessage> messages =
          pipeline.apply(
              Create.timestamped(ImmutableList.of(pubsubMsg))
                  .withCoder(PubsubMessageWithTopicCoder.of()));
      messages.setIsBoundedInternal(PCollection.IsBounded.BOUNDED);
      messages.apply(PubsubIO.writeMessagesDynamic().withClientFactory(factory));
      pipeline.run();
    }
  }