@Override public void onThrowable(Throwable t) { log.warn("[{}] Failed to perform http request: {}", requestUrl, t.getMessage()); future.completeExceptionally(new PulsarClientException(t)); } });
private ByteBuf encryptMessage(MessageMetadata.Builder msgMetadata, ByteBuf compressedPayload) throws PulsarClientException { ByteBuf encryptedPayload = compressedPayload; if (!conf.isEncryptionEnabled() || msgCrypto == null) { return encryptedPayload; } try { encryptedPayload = msgCrypto.encrypt(conf.getEncryptionKeys(), conf.getCryptoKeyReader(), msgMetadata, compressedPayload); } catch (PulsarClientException e) { // Unless config is set to explicitly publish un-encrypted message upon failure, fail the request if (conf.getCryptoFailureAction() == ProducerCryptoFailureAction.SEND) { log.warn("[{}] [{}] Failed to encrypt message {}. Proceeding with publishing unencrypted message", topic, producerName, e.getMessage()); return compressedPayload; } throw e; } return encryptedPayload; }
@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); } }
topic, subscription, allTopicPartitionsNumber.get()); } catch (PulsarClientException e) { log.warn("[{}] Failed startReceivingMessages while subscribe topics: {}", topic, e.getMessage()); subscribeFuture.completeExceptionally(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); } }
private void close() { state = State.Closed; ctx.close(); try { client.close(); } catch (PulsarClientException e) { LOG.error("Unable to close pulsar client - {}. Error - {}", client, e.getMessage()); } }
@Override public AuthenticationDataProvider getAuthData() throws PulsarClientException { try { return new AuthenticationDataTls(certFilePath, keyFilePath); } catch (Exception e) { throw new PulsarClientException(e); } }
private ByteBuf encryptMessage(MessageMetadata.Builder msgMetadata, ByteBuf compressedPayload) throws PulsarClientException { ByteBuf encryptedPayload = compressedPayload; if (!conf.isEncryptionEnabled() || msgCrypto == null) { return encryptedPayload; } try { encryptedPayload = msgCrypto.encrypt(conf.getEncryptionKeys(), conf.getCryptoKeyReader(), msgMetadata, compressedPayload); } catch (PulsarClientException e) { // Unless config is set to explicitly publish un-encrypted message upon failure, fail the request if (conf.getCryptoFailureAction() == ProducerCryptoFailureAction.SEND) { log.warn("[{}] [{}] Failed to encrypt message {}. Proceeding with publishing unencrypted message", topic, producerName, e.getMessage()); return compressedPayload; } throw e; } return encryptedPayload; }
@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 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 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 void acknowledge(MessageId messageId) throws PulsarClientException { try { acknowledgeAsync(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 Consumer<T> subscribe() throws PulsarClientException { try { return subscribeAsync().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 CompletableFuture<Void> seekAsync(MessageId messageId) { return FutureUtil.failedFuture(new PulsarClientException("Seek operation not supported on topics consumer")); }