client/src/main/java/io/hoplin/Publisher.java
/**
   * Publish message asynchronously to a specific exchange on given channel.
   *
   * @param <T>
   * @param channel
   * @param exchange
   * @param routingKey
   * @param props
   * @param body
   * @return
   */
Publish message asynchronously to a specific exchange on given channel.
Publish message asynchronously to a specific exchange on given channel .
public <T> CompletableFuture<Void> basicPublishAsync(final Channel channel, final String exchange,
      final String routingKey, BasicProperties props, byte[] body) {
    Objects.requireNonNull(channel);
    Objects.requireNonNull(exchange);
    Objects.requireNonNull(body);
    return CompletableFuture.runAsync(() -> {
      final QueueMetrics metrics = getInstance(getKey(exchange, routingKey));
      try {
        if (log.isDebugEnabled()) {
          log.debug("Publishing [exchange, routingKey, id] : {}, {}, {}", exchange, routingKey,
              props.getMessageId());
        }
        channel.basicPublish(exchange, routingKey, props, body);
        metrics.markMessageSent();
        metrics.incrementSend(body.length);
      } catch (final IOException e) {
        metrics.markMessagePublishFailed();
        throw new HoplinRuntimeException("Unable to publish message", e);
      }
    }, executor);
  }
public < T > CompletableFuture < Void > basicPublishAsync ( final Channel channel , final String exchange , final String routingKey , BasicProperties props , byte [ ] body ) { Objects . requireNonNull ( channel ) ; Objects . requireNonNull ( exchange ) ; Objects . requireNonNull ( body ) ; return CompletableFuture . runAsync ( ( ) -> { final QueueMetrics metrics = getInstance ( getKey ( exchange , routingKey ) ) ; try { if ( log . isDebugEnabled ( ) ) { log . debug ( "Publishing [exchange, routingKey, id] : {}, {}, {}" , exchange , routingKey , props . getMessageId ( ) ) ; } channel . basicPublish ( exchange , routingKey , props , body ) ; metrics . markMessageSent ( ) ; metrics . incrementSend ( body . length ) ; } catch ( final IOException e ) { metrics . markMessagePublishFailed ( ) ; throw new HoplinRuntimeException ( "Unable to publish message" , e ) ; } } , executor ) ; }
Publish message asynchronously to a specific exchange on given channel.
Publish message asynchronously to a specific exchange on given channel .