Class OpenCensusUtil.OpenCensusMessageReceiver (1.126.6)

public static class OpenCensusUtil.OpenCensusMessageReceiver implements MessageReceiver

Wrapper class for MessageReceiver that decodes any received trace and tag contexts and puts them in scope.

Inheritance

java.lang.Object > OpenCensusUtil.OpenCensusMessageReceiver

Implements

MessageReceiver

Constructors

OpenCensusMessageReceiver(MessageReceiver receiver)

public OpenCensusMessageReceiver(MessageReceiver receiver)
Parameter
NameDescription
receiverMessageReceiver

Methods

receiveMessage(PubsubMessage message, AckReplyConsumer consumer)

public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer)

Called when a message is received by the subscriber. The implementation must arrange for AckReplyConsumer#ack() or AckReplyConsumer#nack() to be called after processing the message.


 // This {@code MessageReceiver} passes all messages to a BlockingQueue. This method can
 // be called concurrently from multiple threads, so it is important that the queue be
 // thread-safe.
 //
 // This example is for illustration. Implementations may directly process messages instead of
 // sending them to queues.
 MessageReceiver receiver =
     new MessageReceiver() {
       public void receiveMessage(final PubsubMessage message, final AckReplyConsumer consumer) {
         if (blockingQueue.offer(message)) {
           consumer.ack();
         } else {
           consumer.nack();
         }
       }
     };

 
Parameters
NameDescription
messagePubsubMessage
consumerAckReplyConsumer