Retry configuration for Activity from external source like application.yaml

@WorkflowImpl(taskQueues = Workflows.TaskQueues.SAMPLE_SHELL)
public class SampleWorkflowImpl implements SampleWorkflow {

    private final SampleActivity activity;

    /**
     * Default constructor for the SampleWorkflowImpl class.
     */
    public SampleWorkflowImpl() {
        // Define retry options with a maximum number of attempts, instead of hardcoding read from application.yaml
        RetryOptions retryOptions = RetryOptions.newBuilder()
                .setMaximumAttempts(1)
                .build();

        // Set activity options with a timeout of 2 minutes
        ActivityOptions activityOptions = ActivityOptions.newBuilder()
                .setStartToCloseTimeout(Duration.parse("PT2M")) // 2 minutes timeout
                .setRetryOptions(retryOptions)
                .build();
        
        // Create an activity stub with the specified options
        this.activity = Workflow.newActivityStub(SampleActivity.class, activityOptions);
    }
}

Additionally, I would like to configure setMaximumAttempts and setStartToCloseTimeout values to be read from the Spring configuration in the application.yaml file. I have also initiated workflows using the auto-discovery feature found at sdk-java/temporal-spring-boot-autoconfigure at master · temporalio/sdk-java · GitHub. Could you please assist me with this?

You should be able to use @Value annotation for example

@Value("${my.app.abc}")
private String abc;

.setMaximumAttempts(1)

Note its not really recommended to disable activity retries. Whats your use case for doing so?

setStartToCloseTimeout(Duration.parse(“PT2M”))

You can also use Duration.ofMinutes(2) if you wanted just fyi.