public static class OpenCensusUtil.OpenCensusMessageReceiver extends Object implements MessageReceiver
MessageReceiver
that decodes any received trace and tag contexts and
puts them in scope.Constructor and Description |
---|
OpenCensusMessageReceiver(MessageReceiver receiver) |
Modifier and Type | Method and Description |
---|---|
void |
receiveMessage(PubsubMessage message,
AckReplyConsumer consumer)
Called when a message is received by the subscriber.
|
public OpenCensusMessageReceiver(MessageReceiver receiver)
public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer)
MessageReceiver
AckReplyConsumer.ack()
or AckReplyConsumer.nack()
to be called after processing the
message
.
// This {@code MessageReceiver} passes all messages to a {@link 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();
}
}
};
receiveMessage
in interface MessageReceiver
Copyright © 2023 Google LLC. All rights reserved.