@Override public void onThrowable(Throwable t) { log.warn("[{}] Failed to perform http request: {}", requestUrl, t.getMessage()); future.completeExceptionally(new PulsarClientException(t)); } });
@Override public void seek(MessageId messageId) throws PulsarClientException { try { seekAsync(messageId).get(); } catch (ExecutionException e) { throw new PulsarClientException(e.getCause()); } catch (InterruptedException e) { throw new PulsarClientException(e); } }
@Override public void close() throws PulsarClientException { try { closeAsync().get(); } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof PulsarClientException) { throw (PulsarClientException) t; } else { throw new PulsarClientException(t); } } catch (InterruptedException e) { throw new PulsarClientException(e); } }
@Override public AuthenticationDataProvider getAuthData() throws PulsarClientException { try { return new AuthenticationDataTls(certFilePath, keyFilePath); } catch (Exception e) { throw new PulsarClientException(e); } }
@Override public void unsubscribe() throws PulsarClientException { try { unsubscribeAsync().get(); } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof PulsarClientException) { throw (PulsarClientException) t; } else { throw new PulsarClientException(t); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
@Override public void close() throws PulsarClientException { try { closeAsync().get(); } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof PulsarClientException) { throw (PulsarClientException) t; } else { throw new PulsarClientException(t); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
@Override public AuthenticationDataProvider getAuthData() throws PulsarClientException { try { return new AuthenticationDataBasic(userId, password); } catch (Exception e) { throw new PulsarClientException(e); } }
@Override public void seek(MessageId messageId) throws PulsarClientException { try { seekAsync(messageId).get(); } catch (ExecutionException | InterruptedException e) { throw new PulsarClientException(e); } }
@Override public Producer<T> create() throws PulsarClientException { try { return createAsync().get(); } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof PulsarClientException) { throw (PulsarClientException) t; } else { throw new PulsarClientException(t); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
@Override public Reader<T> create() throws PulsarClientException { try { return createAsync().get(); } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof PulsarClientException) { throw (PulsarClientException) t; } else { throw new PulsarClientException(t); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
@Override public void acknowledgeCumulative(MessageId messageId) throws PulsarClientException { try { acknowledgeCumulativeAsync(messageId).get(); } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof PulsarClientException) { throw (PulsarClientException) t; } else { throw new PulsarClientException(t); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
@Override public void close() throws PulsarClientException { try { closeAsync().get(); } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof PulsarClientException) { throw (PulsarClientException) t; } else { throw new PulsarClientException(t); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
@Override public void flush() throws PulsarClientException { try { flushAsync().get(); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof PulsarClientException) { throw (PulsarClientException) cause; } else { throw new PulsarClientException(cause); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
@Override public CompletableFuture<Void> seekAsync(MessageId messageId) { return FutureUtil.failedFuture(new PulsarClientException("Seek operation not supported on topics consumer")); }
@Override protected Message<T> internalReceive() throws PulsarClientException { Message<T> message; try { message = incomingMessages.take(); checkState(message instanceof TopicMessageImpl); unAckedMessageTracker.add(message.getMessageId()); resumeReceivingFromPausedConsumersIfNeeded(); return message; } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
@Override protected Message<T> internalReceive(int timeout, TimeUnit unit) throws PulsarClientException { Message<T> message; try { message = incomingMessages.poll(timeout, unit); if (message != null) { checkArgument(message instanceof TopicMessageImpl); unAckedMessageTracker.add(message.getMessageId()); } resumeReceivingFromPausedConsumersIfNeeded(); return message; } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
public boolean hasMessageAvailable() throws PulsarClientException { try { if (lastMessageIdInBroker.compareTo(lastDequeuedMessage) > 0 && ((MessageIdImpl)lastMessageIdInBroker).getEntryId() != -1) { return true; } return hasMessageAvailableAsync().get(); } catch (ExecutionException | InterruptedException e) { throw new PulsarClientException(e); } }
private Void handleConnectionError(Throwable exception) { log.warn("[{}] [{}] Error connecting to broker: {}", state.topic, state.getHandlerName(), exception.getMessage()); connection.connectionFailed(new PulsarClientException(exception)); State state = this.state.getState(); if (state == State.Uninitialized || state == State.Connecting || state == State.Ready) { reconnectLater(exception); } return null; }
@Override public void shutdown() throws PulsarClientException { try { lookup.close(); cnxPool.close(); timer.stop(); externalExecutorProvider.shutdownNow(); conf.getAuthentication().close(); } catch (Throwable t) { log.warn("Failed to shutdown Pulsar client", t); throw new PulsarClientException(t); } }
private void setMessageRoutingMode() throws PulsarClientException { if(conf.getMessageRoutingMode() == null && conf.getCustomMessageRouter() == null) { messageRoutingMode(MessageRoutingMode.RoundRobinPartition); } else if(conf.getMessageRoutingMode() == null && conf.getCustomMessageRouter() != null) { messageRoutingMode(MessageRoutingMode.CustomPartition); } else if((conf.getMessageRoutingMode() == MessageRoutingMode.CustomPartition && conf.getCustomMessageRouter() == null) || (conf.getMessageRoutingMode() != MessageRoutingMode.CustomPartition && conf.getCustomMessageRouter() != null)) { throw new PulsarClientException("When 'messageRouter' is set, 'messageRoutingMode' " + "should be set as " + MessageRoutingMode.CustomPartition); } } }