@Override public CompletableFuture<Void> addRuleAsync(String ruleName, Filter filter) { return this.addRuleAsync(new RuleDescription(ruleName, filter)); }
private void receiveSubscriptionMessage() throws ServiceBusException, InterruptedException { subscriptionClient.registerMessageHandler(new MessageHandler(), new MessageHandlerOptions()); TimeUnit.SECONDS.sleep(5); subscriptionClient.close(); }
SubscriptionClient(MessagingFactory factory, String subscriptionPath, ReceiveMode receiveMode) throws InterruptedException, ServiceBusException { this(receiveMode, subscriptionPath); Utils.completeFuture(this.createPumpAndBrowserAsync(factory)); TRACE_LOGGER.info("Created subscription client to subscripton '{}'", subscriptionPath); }
@Bean @Scope("prototype") @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "azure.servicebus", value = {"topic-name", "subscription-name", "subscription-receive-mode"}) public SubscriptionClient subscriptionClient() throws ServiceBusException, InterruptedException { return new SubscriptionClient(new ConnectionStringBuilder(properties.getConnectionString(), properties.getTopicName() + "/subscriptions/" + properties.getSubscriptionName()), properties.getSubscriptionReceiveMode()); } }
@Override public String getTopicName() { String entityPath = this.getEntityPath(); String[] parts = Pattern.compile(SUBSCRIPTIONS_DELIMITER, Pattern.CASE_INSENSITIVE).split(entityPath, 2); return parts[0]; }
Collection<IMessageSession> getMessageSessions() throws InterruptedException, ServiceBusException { return Utils.completeFuture(this.getMessageSessionsAsync()); }
@Override public Collection<RuleDescription> getRules() throws ServiceBusException, InterruptedException { return Utils.completeFuture(this.getRulesAsync()); }
@Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "azure.servicebus", value = {"topic-name", "subscription-name", "subscription-receive-mode"}) public SubscriptionClient subscriptionClient() throws ServiceBusException, InterruptedException { return new SubscriptionClient(new ConnectionStringBuilder(properties.getConnectionString(), properties.getTopicName() + "/subscriptions/" + properties.getSubscriptionName()), properties.getSubscriptionReceiveMode()); } }
@Override public String getSubscriptionName() { String entityPath = this.getEntityPath(); String[] parts = Pattern.compile(SUBSCRIPTIONS_DELIMITER, Pattern.CASE_INSENSITIVE).split(entityPath, 2); if(parts.length == 2) { return parts[1]; } else { throw new RuntimeException("Invalid entity path in the subscription client."); } } }
Collection<IMessageSession> getMessageSessions(Instant lastUpdatedTime) throws InterruptedException, ServiceBusException { return Utils.completeFuture(this.getMessageSessionsAsync(lastUpdatedTime)); }
@Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "azure.servicebus", value = {"topic-name", "subscription-name", "subscription-receive-mode"}) public SubscriptionClient subscriptionClient() throws ServiceBusException, InterruptedException { trackCustomEvent(); return new SubscriptionClient(new ConnectionStringBuilder(properties.getConnectionString(), properties.getTopicName() + "/subscriptions/" + properties.getSubscriptionName()), properties.getSubscriptionReceiveMode()); }
public SubscriptionClient(URI namespaceEndpointURI, String subscriptionPath, ClientSettings clientSettings, ReceiveMode receiveMode) throws InterruptedException, ServiceBusException { this(receiveMode, subscriptionPath); CompletableFuture<MessagingFactory> factoryFuture = MessagingFactory.createFromNamespaceEndpointURIAsyc(namespaceEndpointURI, clientSettings); Utils.completeFuture(factoryFuture.thenComposeAsync((f) -> this.createPumpAndBrowserAsync(f), MessagingFactory.INTERNAL_THREAD_POOL)); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info("Created subscription client to subscription '{}/{}'", namespaceEndpointURI.toString(), subscriptionPath); } }
@Override public void addRule(RuleDescription ruleDescription) throws InterruptedException, ServiceBusException { Utils.completeFuture(this.addRuleAsync(ruleDescription)); }
@Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "azure.servicebus", value = {"topic-name", "subscription-name", "subscription-receive-mode"}) public SubscriptionClient subscriptionClient() throws ServiceBusException, InterruptedException { trackCustomEvent(); return new SubscriptionClient(new ConnectionStringBuilder(properties.getConnectionString(), properties.getTopicName() + "/subscriptions/" + properties.getSubscriptionName()), properties.getSubscriptionReceiveMode()); }
public SubscriptionClient(ConnectionStringBuilder amqpConnectionStringBuilder, ReceiveMode receiveMode) throws InterruptedException, ServiceBusException { this(receiveMode, amqpConnectionStringBuilder.getEntityPath()); CompletableFuture<MessagingFactory> factoryFuture = MessagingFactory.createFromConnectionStringBuilderAsync(amqpConnectionStringBuilder); Utils.completeFuture(factoryFuture.thenComposeAsync((f) -> this.createPumpAndBrowserAsync(f), MessagingFactory.INTERNAL_THREAD_POOL)); if(TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info("Created subscription client to connection string '{}'", amqpConnectionStringBuilder.toLoggableString()); } }
@Override public void addRule(String ruleName, Filter filter) throws InterruptedException, ServiceBusException { Utils.completeFuture(this.addRuleAsync(ruleName, filter)); }
private ISubscriptionClient createSubscriptionClient(String topicName, String subscription) { if (resourceManagerProvider != null && StringUtils.hasText(namespace)) { ServiceBusNamespace serviceBusNamespace = resourceManagerProvider.getServiceBusNamespaceManager().getOrCreate(namespace); Topic topic = resourceManagerProvider.getServiceBusTopicManager() .getOrCreate(Tuple.of(serviceBusNamespace, topicName)); resourceManagerProvider.getServiceBusTopicSubscriptionManager().getOrCreate(Tuple.of(topic, subscription)); } String subscriptionPath = String.format(SUBSCRIPTION_PATH, topicName, subscription); try { return new SubscriptionClient(new ConnectionStringBuilder(connectionString, subscriptionPath), ReceiveMode.PEEKLOCK); } catch (InterruptedException | ServiceBusException e) { throw new ServiceBusRuntimeException("Failed to create service bus subscription client", e); } }
private ISubscriptionClient createSubscriptionClient(String topicName, String subscription) { if (resourceManagerProvider != null && StringUtils.hasText(namespace)) { ServiceBusNamespace serviceBusNamespace = resourceManagerProvider.getServiceBusNamespaceManager().getOrCreate(namespace); Topic topic = resourceManagerProvider.getServiceBusTopicManager() .getOrCreate(Tuple.of(serviceBusNamespace, topicName)); resourceManagerProvider.getServiceBusTopicSubscriptionManager().getOrCreate(Tuple.of(topic, subscription)); } String subscriptionPath = String.format(SUBSCRIPTION_PATH, topicName, subscription); try { return new SubscriptionClient(new ConnectionStringBuilder(connectionString, subscriptionPath), ReceiveMode.PEEKLOCK); } catch (InterruptedException | ServiceBusException e) { throw new ServiceBusRuntimeException("Failed to create service bus subscription client", e); } }