public interface MessageReceiver
Subscriber
to receive messages.Modifier and Type | Method and Description |
---|---|
void |
receiveMessage(com.google.pubsub.v1.PubsubMessage message,
AckReplyConsumer consumer)
Called when a message is received by the subscriber.
|
void receiveMessage(com.google.pubsub.v1.PubsubMessage message, AckReplyConsumer consumer)
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();
}
}
};
Copyright © 2019 Google LLC. All rights reserved.