Commit a3fe6c8b authored by harshit aggarwal's avatar harshit aggarwal
Browse files

Adding new environment variable

parent 9dcde8b0
Pipeline #6125 passed with stages
in 12 minutes and 30 seconds
......@@ -60,9 +60,12 @@ public class AzureBootstrapConfig {
@Value("${executor-n-threads}")
private String nThreads;
@Value("${max_concurrent_calls}")
@Value("${max-concurrent-calls}")
private String maxConcurrentCalls;
@Value("${max-lock-renew}")
private String maxLockRenewDurationInSeconds;
@Bean
@Named("STORAGE_ACCOUNT_NAME")
public String storageAccount() {
......
......@@ -40,10 +40,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
private void registerMessageHandler(SubscriptionClient subscriptionClient, ExecutorService executorService) {
try {
MessageHandler messageHandler = new MessageHandler(subscriptionClient, processWKSTransform);
subscriptionClient.registerMessageHandler(
messageHandler,
new MessageHandlerOptions(Integer.parseUnsignedInt(azureBootstrapConfig.getMaxConcurrentCalls()), false, Duration.ofMinutes(2)),
new MessageHandlerOptions(Integer.parseUnsignedInt(azureBootstrapConfig.getMaxConcurrentCalls()), false, Duration.ofSeconds(Integer.parseUnsignedInt(azureBootstrapConfig.getMaxLockRenewDurationInSeconds()))),
executorService);
} catch (InterruptedException | ServiceBusException e) {
......
......@@ -49,5 +49,8 @@ STORAGE_API=${storage_service_endpoint}
# Specifies the number of threads to be created on the thread pool
executor-n-threads=${executor_n_threads}
# Specified the maximum number of concurrent calls to the callback the message pump should initiate
max-concurrent-calls=${max_concurrent_calls}
\ No newline at end of file
# Specifies the maximum number of concurrent calls to the callback the message pump should initiate
max-concurrent-calls=${max_concurrent_calls}
# Specifies the maximum duration in seconds within which the lock will be renewed automatically
max-lock-renew=${max_lock_renew_duration_seconds}
\ No newline at end of file
......@@ -20,6 +20,7 @@ import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
public class SubscriptionManagerImplTest {
private static final String maxLockRenewDuration = "60";
private static final String maxConcurrentCalls = "1";
private static final String nThreads = "2";
private static final String errorMessage = "some-error";
......@@ -43,6 +44,7 @@ public class SubscriptionManagerImplTest {
public void init() {
when(azureBootstrapConfig.getMaxConcurrentCalls()).thenReturn(maxConcurrentCalls);
when(azureBootstrapConfig.getNThreads()).thenReturn(nThreads);
when(azureBootstrapConfig.getMaxLockRenewDurationInSeconds()).thenReturn(maxLockRenewDuration);
}
@Test
......@@ -55,6 +57,7 @@ public class SubscriptionManagerImplTest {
verify(azureBootstrapConfig, times(1)).getMaxConcurrentCalls();
verify(azureBootstrapConfig, times(1)).getNThreads();
verify(azureBootstrapConfig, times(1)).getMaxLockRenewDurationInSeconds();
}
@Test
......@@ -67,5 +70,6 @@ public class SubscriptionManagerImplTest {
verify(azureBootstrapConfig, times(1)).getMaxConcurrentCalls();
verify(azureBootstrapConfig, times(1)).getNThreads();
verify(azureBootstrapConfig, times(1)).getMaxLockRenewDurationInSeconds();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment