@Deprecated @Override public void registerMessageHandler(IMessageHandler handler) throws InterruptedException, ServiceBusException { this.registerMessageHandler(handler, new MessageHandlerOptions()); }
private void receiveAndPumpMessage() { if (!this.getIsClosingOrClosed()) { CompletableFuture<IMessage> receiveMessageFuture = this.innerReceiver.receiveAsync(this.messageHandlerOptions.getMessageWaitDuration()); receiveMessageFuture.handleAsync((message, receiveEx) -> { if (receiveEx != null) { Instant stopRenewMessageLockAt = Instant.now().plus(this.messageHandlerOptions.getMaxAutoRenewDuration()); renewLockLoop = new MessgeRenewLockLoop(this.innerReceiver, this, message, stopRenewMessageLockAt); renewLockLoop.startLoop(); if (this.messageHandlerOptions.isAutoComplete()) { TRACE_LOGGER.debug("Completing message with sequence number '{}'", message.getSequenceNumber()); updateDispositionFuture = this.innerReceiver.completeAsync(message.getLockToken()); if(this.messageHandlerOptions.isAutoComplete())
@Override public void registerMessageHandler(IMessageHandler handler, MessageHandlerOptions handlerOptions, ExecutorService executorService) throws InterruptedException, ServiceBusException { assertNonNulls(handler, handlerOptions, executorService); TRACE_LOGGER.info("Registering message handler on entity '{}' with '{}'", this.entityPath, handlerOptions); this.setHandlerRegistered(); this.messageHandler = handler; this.messageHandlerOptions = handlerOptions; this.customCodeExecutor = executorService; this.innerReceiver = ClientFactory.createMessageReceiverFromEntityPath(this.factory, this.entityPath, this.entityType, this.receiveMode); TRACE_LOGGER.info("Created MessageReceiver to entity '{}'", this.entityPath); if(this.prefetchCount != UNSET_PREFETCH_COUNT) { this.innerReceiver.setPrefetchCount(this.prefetchCount); } for (int i = 0; i < handlerOptions.getMaxConcurrentCalls(); i++) { this.receiveAndPumpMessage(); } }
@Override public void registerMessageHandler(IMessageHandler handler, ExecutorService executorService) throws InterruptedException, ServiceBusException { this.registerMessageHandler(handler, new MessageHandlerOptions(), executorService); }
@PostConstruct private void postConstruct() { LOG.debug("postConstruct start..."); try { LOG.debug("registering queue handler..."); queueClientForReceiving.registerMessageHandler(new MessageHandler(), new MessageHandlerOptions()); LOG.debug("done registering handlers..."); } catch (InterruptedException e) { LOG.error("Error registering message handler", e); } catch (ServiceBusException e) { LOG.error("Error registering message handler", e); } LOG.debug("postConstruct end."); }
private void receiveSubscriptionMessage() throws ServiceBusException, InterruptedException { subscriptionClient.registerMessageHandler(new MessageHandler(), new MessageHandlerOptions()); TimeUnit.SECONDS.sleep(5); subscriptionClient.close(); }
private void receiveQueueMessage() throws ServiceBusException, InterruptedException { queueClient.registerMessageHandler(new MessageHandler(), new MessageHandlerOptions()); TimeUnit.SECONDS.sleep(5); queueClient.close(); }
private static void receiveMessages(QueueClient queueClient) throws InterruptedException, ServiceBusException { queueClient.registerMessageHandler(new IMessageHandler() { public CompletableFuture<Void> onMessageAsync(IMessage message) { return CompletableFuture.completedFuture(null); } public void notifyException(Throwable exception, ExceptionPhase phase) {} }, new MessageHandlerOptions(10000, true, Duration.ofMinutes(2))); } }