Class PubsubMessage.Builder (1.133.1)

public static final class PubsubMessage.Builder extends GeneratedMessageV3.Builder<PubsubMessage.Builder> implements PubsubMessageOrBuilder

A message that is published by publishers and consumed by subscribers. The message must contain either a non-empty data field or at least one attribute. Note that client libraries represent this object differently depending on the language. See the corresponding client library documentation for more information. See quotas and limits for more information about message limits.

Protobuf type google.pubsub.v1.PubsubMessage

Static Methods

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

Methods

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public PubsubMessage.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
PubsubMessage.Builder
Overrides

build()

public PubsubMessage build()
Returns
Type Description
PubsubMessage

buildPartial()

public PubsubMessage buildPartial()
Returns
Type Description
PubsubMessage

clear()

public PubsubMessage.Builder clear()
Returns
Type Description
PubsubMessage.Builder
Overrides

clearAttributes()

public PubsubMessage.Builder clearAttributes()
Returns
Type Description
PubsubMessage.Builder

clearData()

public PubsubMessage.Builder clearData()

Optional. The message data field. If this field is empty, the message must contain at least one attribute.

bytes data = 1 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
PubsubMessage.Builder

This builder for chaining.

clearField(Descriptors.FieldDescriptor field)

public PubsubMessage.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
Name Description
field FieldDescriptor
Returns
Type Description
PubsubMessage.Builder
Overrides

clearMessageId()

public PubsubMessage.Builder clearMessageId()

ID of this message, assigned by the server when the message is published. Guaranteed to be unique within the topic. This value may be read by a subscriber that receives a PubsubMessage via a Pull call or a push delivery. It must not be populated by the publisher in a Publish call.

string message_id = 3;

Returns
Type Description
PubsubMessage.Builder

This builder for chaining.

clearOneof(Descriptors.OneofDescriptor oneof)

public PubsubMessage.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
Name Description
oneof OneofDescriptor
Returns
Type Description
PubsubMessage.Builder
Overrides

clearOrderingKey()

public PubsubMessage.Builder clearOrderingKey()

Optional. If non-empty, identifies related messages for which publish order should be respected. If a Subscription has enable_message_ordering set to true, messages published with the same non-empty ordering_key value will be delivered to subscribers in the order in which they are received by the Pub/Sub system. All PubsubMessages published in a given PublishRequest must specify the same ordering_key value. For more information, see ordering messages.

string ordering_key = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
PubsubMessage.Builder

This builder for chaining.

clearPublishTime()

public PubsubMessage.Builder clearPublishTime()

The time at which the message was published, populated by the server when it receives the Publish call. It must not be populated by the publisher in a Publish call.

.google.protobuf.Timestamp publish_time = 4;

Returns
Type Description
PubsubMessage.Builder

clone()

public PubsubMessage.Builder clone()
Returns
Type Description
PubsubMessage.Builder
Overrides

containsAttributes(String key)

public boolean containsAttributes(String key)

Optional. Attributes for this message. If this field is empty, the message must contain non-empty data. This can be used to filter messages on the subscription.

map<string, string> attributes = 2 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
key String
Returns
Type Description
boolean

getAttributes() (deprecated)

public Map<String,String> getAttributes()

Use #getAttributesMap() instead.

Returns
Type Description
Map<String,String>

getAttributesCount()

public int getAttributesCount()

Optional. Attributes for this message. If this field is empty, the message must contain non-empty data. This can be used to filter messages on the subscription.

map<string, string> attributes = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
int

getAttributesMap()

public Map<String,String> getAttributesMap()

Optional. Attributes for this message. If this field is empty, the message must contain non-empty data. This can be used to filter messages on the subscription.

map<string, string> attributes = 2 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
Map<String,String>

getAttributesOrDefault(String key, String defaultValue)

public String getAttributesOrDefault(String key, String defaultValue)

Optional. Attributes for this message. If this field is empty, the message must contain non-empty data. This can be used to filter messages on the subscription.

map<string, string> attributes = 2 [(.google.api.field_behavior) = OPTIONAL];

Parameters
Name Description
key String
defaultValue String
Returns
Type Description
String

getAttributesOrThrow(String key)

public String getAttributesOrThrow(String key)

Optional. Attributes for this message. If this field is empty, the message must contain non-empty data. This can be used to filter messages on the subscription.

map<string, string> attributes = 2 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
key String
Returns
Type Description
String

getData()

public ByteString getData()

Optional. The message data field. If this field is empty, the message must contain at least one attribute.

bytes data = 1 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
ByteString

The data.

getDefaultInstanceForType()

public PubsubMessage getDefaultInstanceForType()
Returns
Type Description
PubsubMessage

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
Type Description
Descriptor
Overrides

getMessageId()

public String getMessageId()

ID of this message, assigned by the server when the message is published. Guaranteed to be unique within the topic. This value may be read by a subscriber that receives a PubsubMessage via a Pull call or a push delivery. It must not be populated by the publisher in a Publish call.

string message_id = 3;

Returns
Type Description
String

The messageId.

getMessageIdBytes()

public ByteString getMessageIdBytes()

ID of this message, assigned by the server when the message is published. Guaranteed to be unique within the topic. This value may be read by a subscriber that receives a PubsubMessage via a Pull call or a push delivery. It must not be populated by the publisher in a Publish call.

string message_id = 3;

Returns
Type Description
ByteString

The bytes for messageId.

getMutableAttributes() (deprecated)

public Map<String,String> getMutableAttributes()

Use alternate mutation accessors instead.

Returns
Type Description
Map<String,String>

getOrderingKey()

public String getOrderingKey()

Optional. If non-empty, identifies related messages for which publish order should be respected. If a Subscription has enable_message_ordering set to true, messages published with the same non-empty ordering_key value will be delivered to subscribers in the order in which they are received by the Pub/Sub system. All PubsubMessages published in a given PublishRequest must specify the same ordering_key value. For more information, see ordering messages.

string ordering_key = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
String

The orderingKey.

getOrderingKeyBytes()

public ByteString getOrderingKeyBytes()

Optional. If non-empty, identifies related messages for which publish order should be respected. If a Subscription has enable_message_ordering set to true, messages published with the same non-empty ordering_key value will be delivered to subscribers in the order in which they are received by the Pub/Sub system. All PubsubMessages published in a given PublishRequest must specify the same ordering_key value. For more information, see ordering messages.

string ordering_key = 5 [(.google.api.field_behavior) = OPTIONAL];

Returns
Type Description
ByteString

The bytes for orderingKey.

getPublishTime()

public Timestamp getPublishTime()

The time at which the message was published, populated by the server when it receives the Publish call. It must not be populated by the publisher in a Publish call.

.google.protobuf.Timestamp publish_time = 4;

Returns
Type Description
Timestamp

The publishTime.

getPublishTimeBuilder()

public Timestamp.Builder getPublishTimeBuilder()

The time at which the message was published, populated by the server when it receives the Publish call. It must not be populated by the publisher in a Publish call.

.google.protobuf.Timestamp publish_time = 4;

Returns
Type Description
Builder

getPublishTimeOrBuilder()

public TimestampOrBuilder getPublishTimeOrBuilder()

The time at which the message was published, populated by the server when it receives the Publish call. It must not be populated by the publisher in a Publish call.

.google.protobuf.Timestamp publish_time = 4;

Returns
Type Description
TimestampOrBuilder

hasPublishTime()

public boolean hasPublishTime()

The time at which the message was published, populated by the server when it receives the Publish call. It must not be populated by the publisher in a Publish call.

.google.protobuf.Timestamp publish_time = 4;

Returns
Type Description
boolean

Whether the publishTime field is set.

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

internalGetMapFieldReflection(int number)

protected MapFieldReflectionAccessor internalGetMapFieldReflection(int number)
Parameter
Name Description
number int
Returns
Type Description
com.google.protobuf.MapFieldReflectionAccessor
Overrides
com.google.protobuf.GeneratedMessageV3.Builder.internalGetMapFieldReflection(int)

internalGetMutableMapFieldReflection(int number)

protected MapFieldReflectionAccessor internalGetMutableMapFieldReflection(int number)
Parameter
Name Description
number int
Returns
Type Description
com.google.protobuf.MapFieldReflectionAccessor
Overrides
com.google.protobuf.GeneratedMessageV3.Builder.internalGetMutableMapFieldReflection(int)

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public PubsubMessage.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
PubsubMessage.Builder
Overrides
Exceptions
Type Description
IOException

mergeFrom(Message other)

public PubsubMessage.Builder mergeFrom(Message other)
Parameter
Name Description
other Message
Returns
Type Description
PubsubMessage.Builder
Overrides

mergeFrom(PubsubMessage other)

public PubsubMessage.Builder mergeFrom(PubsubMessage other)
Parameter
Name Description
other PubsubMessage
Returns
Type Description
PubsubMessage.Builder

mergePublishTime(Timestamp value)

public PubsubMessage.Builder mergePublishTime(Timestamp value)

The time at which the message was published, populated by the server when it receives the Publish call. It must not be populated by the publisher in a Publish call.

.google.protobuf.Timestamp publish_time = 4;

Parameter
Name Description
value Timestamp
Returns
Type Description
PubsubMessage.Builder

mergeUnknownFields(UnknownFieldSet unknownFields)

public final PubsubMessage.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
PubsubMessage.Builder
Overrides

putAllAttributes(Map<String,String> values)

public PubsubMessage.Builder putAllAttributes(Map<String,String> values)

Optional. Attributes for this message. If this field is empty, the message must contain non-empty data. This can be used to filter messages on the subscription.

map<string, string> attributes = 2 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
values Map<String,String>
Returns
Type Description
PubsubMessage.Builder

putAttributes(String key, String value)

public PubsubMessage.Builder putAttributes(String key, String value)

Optional. Attributes for this message. If this field is empty, the message must contain non-empty data. This can be used to filter messages on the subscription.

map<string, string> attributes = 2 [(.google.api.field_behavior) = OPTIONAL];

Parameters
Name Description
key String
value String
Returns
Type Description
PubsubMessage.Builder

removeAttributes(String key)

public PubsubMessage.Builder removeAttributes(String key)

Optional. Attributes for this message. If this field is empty, the message must contain non-empty data. This can be used to filter messages on the subscription.

map<string, string> attributes = 2 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
key String
Returns
Type Description
PubsubMessage.Builder

setData(ByteString value)

public PubsubMessage.Builder setData(ByteString value)

Optional. The message data field. If this field is empty, the message must contain at least one attribute.

bytes data = 1 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
value ByteString

The data to set.

Returns
Type Description
PubsubMessage.Builder

This builder for chaining.

setField(Descriptors.FieldDescriptor field, Object value)

public PubsubMessage.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
PubsubMessage.Builder
Overrides

setMessageId(String value)

public PubsubMessage.Builder setMessageId(String value)

ID of this message, assigned by the server when the message is published. Guaranteed to be unique within the topic. This value may be read by a subscriber that receives a PubsubMessage via a Pull call or a push delivery. It must not be populated by the publisher in a Publish call.

string message_id = 3;

Parameter
Name Description
value String

The messageId to set.

Returns
Type Description
PubsubMessage.Builder

This builder for chaining.

setMessageIdBytes(ByteString value)

public PubsubMessage.Builder setMessageIdBytes(ByteString value)

ID of this message, assigned by the server when the message is published. Guaranteed to be unique within the topic. This value may be read by a subscriber that receives a PubsubMessage via a Pull call or a push delivery. It must not be populated by the publisher in a Publish call.

string message_id = 3;

Parameter
Name Description
value ByteString

The bytes for messageId to set.

Returns
Type Description
PubsubMessage.Builder

This builder for chaining.

setOrderingKey(String value)

public PubsubMessage.Builder setOrderingKey(String value)

Optional. If non-empty, identifies related messages for which publish order should be respected. If a Subscription has enable_message_ordering set to true, messages published with the same non-empty ordering_key value will be delivered to subscribers in the order in which they are received by the Pub/Sub system. All PubsubMessages published in a given PublishRequest must specify the same ordering_key value. For more information, see ordering messages.

string ordering_key = 5 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
value String

The orderingKey to set.

Returns
Type Description
PubsubMessage.Builder

This builder for chaining.

setOrderingKeyBytes(ByteString value)

public PubsubMessage.Builder setOrderingKeyBytes(ByteString value)

Optional. If non-empty, identifies related messages for which publish order should be respected. If a Subscription has enable_message_ordering set to true, messages published with the same non-empty ordering_key value will be delivered to subscribers in the order in which they are received by the Pub/Sub system. All PubsubMessages published in a given PublishRequest must specify the same ordering_key value. For more information, see ordering messages.

string ordering_key = 5 [(.google.api.field_behavior) = OPTIONAL];

Parameter
Name Description
value ByteString

The bytes for orderingKey to set.

Returns
Type Description
PubsubMessage.Builder

This builder for chaining.

setPublishTime(Timestamp value)

public PubsubMessage.Builder setPublishTime(Timestamp value)

The time at which the message was published, populated by the server when it receives the Publish call. It must not be populated by the publisher in a Publish call.

.google.protobuf.Timestamp publish_time = 4;

Parameter
Name Description
value Timestamp
Returns
Type Description
PubsubMessage.Builder

setPublishTime(Timestamp.Builder builderForValue)

public PubsubMessage.Builder setPublishTime(Timestamp.Builder builderForValue)

The time at which the message was published, populated by the server when it receives the Publish call. It must not be populated by the publisher in a Publish call.

.google.protobuf.Timestamp publish_time = 4;

Parameter
Name Description
builderForValue Builder
Returns
Type Description
PubsubMessage.Builder

setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)

public PubsubMessage.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
Name Description
field FieldDescriptor
index int
value Object
Returns
Type Description
PubsubMessage.Builder
Overrides

setUnknownFields(UnknownFieldSet unknownFields)

public final PubsubMessage.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
PubsubMessage.Builder
Overrides