Creating an AzureApi with a Custom ExecutorService
This guide will walk you through the process of creating an AzureApiBuilder with a custom ExecutorService.
Steps
Create a custom ExecutorService
For this example, we'll create a custom
ExecutorServiceusing the Virtual Threads API introduced in Java 21:javaExecutorService customExecutorService = Executors.newVirtualThreadPerTaskExecutor();Create an AzureApiBuilder
You can create an
AzureApiby using theAzureApiBuilderclass. Here's an example:javaString azureKey = "<Your Azure Subscription Key>"; String azureRegion = "<Your Azure Subscription Region>"; AzureApi azureApi = new AzureApiBuilder() .setKey(azureKey) .region(azureRegion) .executorService(customExecutorService).build();This will create an
AzureApiwith the settings you specified in theAzureApiBuilder.
That's it! You've successfully created an AzureApi with a custom ExecutorService. You can now use this AzureApi to make requests to the Azure API.