public final class ReceivedMessage extends Message
Message as well as the acknowledge id. The ack id can be used to acknowledge the received
message.
ReceivedMessage also adds a layer of service-related functionality over
Message that help manage received messages (see ack(), nack() and
modifyAckDeadline(int, TimeUnit)).
| Modifier and Type | Class and Description |
|---|---|
static class |
ReceivedMessage.Builder |
| Modifier and Type | Method and Description |
|---|---|
void |
ack()
Acknowledges the current message.
|
Future<Void> |
ackAsync()
Sends a request to acknowledge the current message.
|
String |
ackId()
Returns the acknowledge id of the message.
|
boolean |
equals(Object obj) |
int |
hashCode() |
void |
modifyAckDeadline(int deadline,
TimeUnit unit)
Modifies the acknowledge deadline of the current message.
|
Future<Void> |
modifyAckDeadlineAsync(int deadline,
TimeUnit unit)
Sends a request to modify the acknowledge deadline of the given messages.
|
void |
nack()
"Nacks" the current message.
|
Future<Void> |
nackAsync()
Sends a request to "nack" the current message.
|
PubSub |
pubsub()
Returns the received message's
PubSub object used to issue requests. |
String |
subscription()
Returns the name of the subscription this message was received from.
|
ReceivedMessage.Builder |
toBuilder()
Returns a builder for the message object.
|
attributes, builder, builder, id, of, of, payload, payloadAsString, publishTime, toStringpublic ReceivedMessage.Builder toBuilder()
Messagepublic PubSub pubsub()
PubSub object used to issue requests.public String subscription()
public String ackId()
public void ack()
PubSubException - upon failure, or if the subscription was not foundpublic Future<Void> ackAsync()
Future object
that can be used to wait for the acknowledge operation to be completed.PubSubException - upon failure, or if the subscription was not foundpublic void nack()
modifyAckDeadline(int, TimeUnit) with a deadline of 0.PubSubException - upon failure, or if the subscription was not foundpublic Future<Void> nackAsync()
modifyAckDeadlineAsync(int, TimeUnit) with a deadline of 0. The method returns a
Future object that can be used to wait for the "nack" operation to be completed.PubSubException - upon failure, or if the subscription was not foundpublic void modifyAckDeadline(int deadline,
TimeUnit unit)
deadline must be >= 0 and
is the new deadline with respect to the time the modify request was received by the Pub/Sub
service. For example, if deadline is 10 and unit is TimeUnit.SECONDS,
the new ack deadline will expire 10 seconds after the modify request was received by the
service. Specifying 0 may be used to make the message available for another pull request
(corresponds to calling nack().deadline - the new deadline, relative to the time the modify request is received by the
Pub/Sub serviceunit - deadline time unitPubSubException - upon failure, or if the subscription was not foundpublic Future<Void> modifyAckDeadlineAsync(int deadline, TimeUnit unit)
deadline
must be >= 0 and is the new deadline with respect to the time the modify request was
received by the Pub/Sub service. For example, if deadline is 10 and unit is
TimeUnit.SECONDS, the new ack deadline will expire 10 seconds after the modify request
was received by the service. Specifying 0 may be used to make the message available for another
pull request (corresponds to calling nackAsync(). The method returns a Future
object that can be used to wait for the modify operation to be completed.deadline - the new deadline, relative to the time the modify request is received by the
Pub/Sub serviceunit - deadline time unitPubSubException - upon failure, or if the subscription was not foundCopyright © 2016 Google. All rights reserved.