Class RabbitMQSender

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public final class RabbitMQSender
    extends Sender
    This sends (usually json v2) encoded spans to a RabbitMQ queue.

    Usage

    This type is designed for the async reporter.

    Here's a simple configuration, configured for json:

    
     sender = RabbitMQSender.create("localhost:5672");
     

    Here's an example with an explicit SSL connection factory and protocol buffers encoding:

    
     connectionFactory = new ConnectionFactory();
     connectionFactory.setHost("localhost");
     connectionFactory.setPort(5671);
     connectionFactory.useSslProtocol();
     sender = RabbitMQSender.newBuilder()
       .connectionFactory(connectionFactory)
       .encoding(Encoding.PROTO3)
       .build();
     

    Compatibility with Zipkin Server

    Zipkin server should be v2.1 or higher.

    Implementation Notes

    The sender does not use RabbitMQ Publisher Confirms, so messages considered sent may not necessarily be received by consumers in case of RabbitMQ failure.

    This sender is thread-safe: a channel is created for each thread that calls sendSpans(List).

    • Method Detail

      • create

        public static RabbitMQSender create​(java.lang.String addresses)
        Creates a sender that sends Encoding.JSON messages.
      • encoding

        public zipkin2.codec.Encoding encoding()
        Specified by:
        encoding in class Sender
      • messageSizeInBytes

        public int messageSizeInBytes​(java.util.List<byte[]> encodedSpans)
        Specified by:
        messageSizeInBytes in class Sender
      • messageSizeInBytes

        public int messageSizeInBytes​(int encodedSizeInBytes)
        Overrides:
        messageSizeInBytes in class Sender
      • sendSpans

        public zipkin2.Call<java.lang.Void> sendSpans​(java.util.List<byte[]> encodedSpans)
        This sends all of the spans as a single message.
        Specified by:
        sendSpans in class Sender
      • check

        public zipkin2.CheckResult check()
        Ensures there are no connection issues.
        Overrides:
        check in class zipkin2.Component
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class zipkin2.Component
        Throws:
        java.io.IOException