public static <EventT> Write<EventT> write() {
    return new AutoValue_JmsIO_Write.Builder<EventT>().build();
  }
@Test
  public void testWriteMessageWithRetryPolicy() throws Exception {
    int waitingSeconds = 5;
    // Margin of the pipeline execution in seconds that should be taken into consideration
    int pipelineDuration = 5;
    Instant now = Instant.now();
    String messageText = now.toString();
    List<String> data = Collections.singletonList(messageText);
    RetryConfiguration retryPolicy =
        RetryConfiguration.create(
            3, Duration.standardSeconds(waitingSeconds), Duration.standardDays(10));

    WriteJmsResult<String> output =
        pipeline
            .apply(Create.of(data))
            .apply(
                JmsIO.<String>write()
                    .withConnectionFactory(connectionFactory)
                    .withValueMapper(new TextMessageMapperWithErrorCounter())
                    .withRetryConfiguration(retryPolicy)
                    .withQueue(QUEUE)
                    .withUsername(USERNAME)
                    .withPassword(PASSWORD));

    PAssert.that(output.getFailedMessages()).empty();
    pipeline.run();

    Connection connection = connectionFactory.createConnection(USERNAME, PASSWORD);
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = session.createConsumer(session.createQueue(QUEUE));

    Message message = consumer.receive(1000);
    assertNotNull(message);
    long maximumTimestamp =
        now.plus(java.time.Duration.ofSeconds(waitingSeconds + pipelineDuration)).toEpochMilli();
    assertThat(
        message.getJMSTimestamp(),
        allOf(greaterThanOrEqualTo(now.toEpochMilli()), lessThan(maximumTimestamp)));
    assertNull(consumer.receiveNoWait());
  }