I'm attempting the following request from two different classes (Test class and Service class)-
serviceURL.listContainersSegment(null, new ListContainersOptions()).blockingGet().body().containerItems().forEach(container -> {
System.out.println("createServiceUrl | Container "+container.name());
});
Test class results:
The request gets executed as it should and I'm getting the names of the container in my Azure storage account. The request is made and verified using Wireshark
Service class results:
- The request is not being made from this class, checked this using Wireshark.
- The thread gets blocked and no exception is being thrown or no other errors occur in any of the log files where logs are written.
NOTE: Service class is present as a jar and deployed as a Vertx verticle in another application.
Code Details: This function will simply return the ServiceURL object. This method is called from another method onRequest (mentioned further) in the same class.
* Create Service URL
* @param storageAccountName
* @param storageAccountKey
* @param endpointUrl
* @return
* @throws InvalidKeyException
* @throws MalformedURLException
*/
private ServiceURL createServiceUrl(String storageAccountName, String storageAccountKey, String endpointUrl, String endpointProtocol) throws InvalidKeyException, MalformedURLException {
ServiceURL serviceURL = null;
try {
FlintLogger.JOB_LOGGER.info("createServiceUrl | Creating Service URL");
FlintLogger.JOB_LOGGER.debug("createServiceUrl | Creating Service URL with inputs: \n"+storageAccountName+"\n"+storageAccountKey+"\n"+endpointUrl+"\n"+endpointProtocol);
// Use your Storage account's name and key to create a credential object; this is used to access your account.
SharedKeyCredentials credential = new SharedKeyCredentials(storageAccountName, storageAccountKey);
FlintLogger.JOB_LOGGER.info("createServiceUrl | Storage credentials created "+credential.toString());
/*
Create a request pipeline that is used to process HTTP(S) requests and responses. It requires your accont
credentials. In more advanced scenarios, you can configure telemetry, retry policies, logging, and other
options. Also you can configure multiple pipelines for different scenarios.
*/
HttpPipeline pipeline = StorageURL.createPipeline(credential, new PipelineOptions());
FlintLogger.JOB_LOGGER.info("createServiceUrl | Created Http pipeline "+pipeline);
/*
From the Azure portal, get your Storage account blob service URL endpoint.
The URL typically looks like this:
*/
URL url = new URL(String.format(Locale.ROOT, endpointProtocol+"://%s.blob."+endpointUrl, storageAccountName));
FlintLogger.JOB_LOGGER.debug("createServiceUrl | Created Url with specified endpoint "+url.toString());
// Create a ServiceURL object that wraps the service URL and a request pipeline.
serviceURL = new ServiceURL(url, pipeline);
FlintLogger.JOB_LOGGER.debug("createServiceUrl | ServiceUrl structure: "+serviceURL.toURL().toString());
FlintLogger.JOB_LOGGER.info("createServiceUrl | Created service URL");
}catch(Exception e) {
FlintLogger.JOB_LOGGER.error("createServiceUrl | Exception: ",e.getMessage());
}
return serviceURL;
}
onRequest method:
try {
// Create Service URL
ServiceURL serviceUrl = createServiceUrl(storageAccountName, storageAccountKey, endpointUrl, endpointProtocol);
FlintLogger.JOB_LOGGER.debug("onRequest | serviceUrl "+serviceUrl.toURL());
FlintLogger.JOB_LOGGER.debug("onRequest | serviceUrl Before request"+serviceUrl.toURL());
try {
serviceUrl.listContainersSegment(null, new ListContainersOptions()).blockingGet().body().containerItems().forEach(container -> {
FlintLogger.JOB_LOGGER.debug("onRequest | Blocking get : "+container.name());
});
}catch(Exception e) {
FlintLogger.JOB_LOGGER.error("Error in thread blocking request ", e.getLocalizedMessage());
}