@Bean @Scope("prototype") @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "azure.servicebus", value = {"queue-name", "queue-receive-mode"}) public QueueClient queueClient() throws InterruptedException, ServiceBusException { return new QueueClient(new ConnectionStringBuilder(properties.getConnectionString(), properties.getQueueName()), properties.getQueueReceiveMode()); }
@Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "azure.servicebus", value = {"queue-name", "queue-receive-mode"}) public QueueClient queueClient() throws InterruptedException, ServiceBusException { return new QueueClient(new ConnectionStringBuilder(properties.getConnectionString(), properties.getQueueName()), properties.getQueueReceiveMode()); }
@Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "azure.servicebus", value = {"queue-name", "queue-receive-mode"}) public QueueClient queueClient() throws InterruptedException, ServiceBusException { trackCustomEvent(); return new QueueClient(new ConnectionStringBuilder(properties.getConnectionString(), properties.getQueueName()), properties.getQueueReceiveMode()); }
@Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "azure.servicebus", value = {"queue-name", "queue-receive-mode"}) public QueueClient queueClient() throws InterruptedException, ServiceBusException { trackCustomEvent(); return new QueueClient(new ConnectionStringBuilder(properties.getConnectionString(), properties.getQueueName()), properties.getQueueReceiveMode()); }
AzureSBManagedConnection(AzureSBManagedConnectionFactory aThis, Subject subject, ConnectionRequestInfo cxRequestInfo) { cf = aThis; listeners = new HashSet<>(); SharedAccessSignatureTokenProvider tokenProvider = new SharedAccessSignatureTokenProvider(cf.getSasKeyName(), cf.getSasKey(), 60); try { sbConnector = new QueueClient(cf.getNameSpace(),cf.getQueueName(),new ClientSettings(tokenProvider, RetryPolicy.getDefault(), Duration.ofSeconds(cf.getTimeOut())),ReceiveMode.RECEIVEANDDELETE); } catch (InterruptedException | ServiceBusException ex) { Logger.getLogger(AzureSBManagedConnection.class.getName()).log(Level.SEVERE, null, ex); } }
AzureSBManagedConnection(AzureSBManagedConnectionFactory aThis, Subject subject, ConnectionRequestInfo cxRequestInfo) { cf = aThis; listeners = new HashSet<>(); SharedAccessSignatureTokenProvider tokenProvider = new SharedAccessSignatureTokenProvider(cf.getSasKeyName(), cf.getSasKey(), 60); try { sbConnector = new QueueClient(cf.getNameSpace(),cf.getQueueName(),new ClientSettings(tokenProvider, RetryPolicy.getDefault(), Duration.ofSeconds(cf.getTimeOut())),ReceiveMode.RECEIVEANDDELETE); } catch (InterruptedException | ServiceBusException ex) { Logger.getLogger(AzureSBManagedConnection.class.getName()).log(Level.SEVERE, null, ex); } }
public AzureSBListener(AzureSBActivationSpec asbSpec, BootstrapContext context, MessageEndpointFactory endpointFactory) throws ResourceException { activationSpec = asbSpec; this.context = context; this.endpointFactory = endpointFactory; SharedAccessSignatureTokenProvider tokenProvider = new SharedAccessSignatureTokenProvider(asbSpec.getSasKeyName(), asbSpec.getSasKey(),60); ClientSettings settings = new ClientSettings(tokenProvider, RetryPolicy.getDefault(), Duration.ofSeconds(asbSpec.getPollTimeout())); try { client = new QueueClient(asbSpec.getNameSpace(), asbSpec.getQueueName(), settings, ReceiveMode.RECEIVEANDDELETE); client.setPrefetchCount(activationSpec.getPreFetchCount()); } catch (InterruptedException | ServiceBusException ex) { Logger.getLogger(AzureSBListener.class.getName()).log(Level.SEVERE, "Error creating listener for queue " + activationSpec.getQueueName(), ex); throw new ResourceException(ex); } }
public AzureSBListener(AzureSBActivationSpec asbSpec, BootstrapContext context, MessageEndpointFactory endpointFactory) throws ResourceException { activationSpec = asbSpec; this.context = context; this.endpointFactory = endpointFactory; SharedAccessSignatureTokenProvider tokenProvider = new SharedAccessSignatureTokenProvider(asbSpec.getSasKeyName(), asbSpec.getSasKey(),60); ClientSettings settings = new ClientSettings(tokenProvider, RetryPolicy.getDefault(), Duration.ofSeconds(asbSpec.getPollTimeout())); try { client = new QueueClient(asbSpec.getNameSpace(), asbSpec.getQueueName(), settings, ReceiveMode.RECEIVEANDDELETE); client.setPrefetchCount(activationSpec.getPreFetchCount()); } catch (InterruptedException | ServiceBusException ex) { Logger.getLogger(AzureSBListener.class.getName()).log(Level.SEVERE, "Error creating listener for queue " + activationSpec.getQueueName(), ex); throw new ResourceException(ex); } }
private IQueueClient createQueueClient(String destination) { if (resourceManagerProvider != null && StringUtils.hasText(namespace)) { ServiceBusNamespace serviceBusNamespace = resourceManagerProvider.getServiceBusNamespaceManager().getOrCreate(namespace); resourceManagerProvider.getServiceBusQueueManager().getOrCreate(Tuple.of(serviceBusNamespace, destination)); } try { return new QueueClient(new ConnectionStringBuilder(connectionString, destination), ReceiveMode.PEEKLOCK); } catch (InterruptedException | ServiceBusException e) { throw new ServiceBusRuntimeException("Failed to create service bus queue client", e); } }
private IQueueClient createQueueClient(String destination) { if (resourceManagerProvider != null && StringUtils.hasText(namespace)) { ServiceBusNamespace serviceBusNamespace = resourceManagerProvider.getServiceBusNamespaceManager().getOrCreate(namespace); resourceManagerProvider.getServiceBusQueueManager().getOrCreate(Tuple.of(serviceBusNamespace, destination)); } try { return new QueueClient(new ConnectionStringBuilder(connectionString, destination), ReceiveMode.PEEKLOCK); } catch (InterruptedException | ServiceBusException e) { throw new ServiceBusRuntimeException("Failed to create service bus queue client", e); } }
public static void consumeMessages() throws Exception { assumeHasAzureSBEnv(); final String connectionString = azureSBConnectionStringFromEnv(); final QueueClient queueClient = new QueueClient(new ConnectionStringBuilder(connectionString), ReceiveMode.PeekLock); receiveMessages(queueClient); Thread.sleep(getAzureTimeoutFromEnvInMillis()); queueClient.close(); }