Class PubsubMessage.Builder (1.118.0)

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
TypeDescription
Descriptor

Methods

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public PubsubMessage.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
NameDescription
fieldFieldDescriptor
valueObject
Returns
TypeDescription
PubsubMessage.Builder
Overrides

build()

public PubsubMessage build()
Returns
TypeDescription
PubsubMessage

buildPartial()

public PubsubMessage buildPartial()
Returns
TypeDescription
PubsubMessage

clear()

public PubsubMessage.Builder clear()
Returns
TypeDescription
PubsubMessage.Builder
Overrides

clearAttributes()

public PubsubMessage.Builder clearAttributes()
Returns
TypeDescription
PubsubMessage.Builder

clearData()

public PubsubMessage.Builder clearData()

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

bytes data = 1;

Returns
TypeDescription
PubsubMessage.Builder

This builder for chaining.

clearField(Descriptors.FieldDescriptor field)

public PubsubMessage.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
NameDescription
fieldFieldDescriptor
Returns
TypeDescription
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
TypeDescription
PubsubMessage.Builder

This builder for chaining.

clearOneof(Descriptors.OneofDescriptor oneof)

public PubsubMessage.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
NameDescription
oneofOneofDescriptor
Returns
TypeDescription
PubsubMessage.Builder
Overrides

clearOrderingKey()

public PubsubMessage.Builder clearOrderingKey()

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.

string ordering_key = 5;

Returns
TypeDescription
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
TypeDescription
PubsubMessage.Builder

clone()

public PubsubMessage.Builder clone()
Returns
TypeDescription
PubsubMessage.Builder
Overrides

containsAttributes(String key)

public boolean containsAttributes(String key)

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;

Parameter
NameDescription
keyString
Returns
TypeDescription
boolean

getAttributes()

public Map<String,String> getAttributes()

Use #getAttributesMap() instead.

Returns
TypeDescription
Map<String,String>

getAttributesCount()

public int getAttributesCount()

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;

Returns
TypeDescription
int

getAttributesMap()

public Map<String,String> getAttributesMap()

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;

Returns
TypeDescription
Map<String,String>

getAttributesOrDefault(String key, String defaultValue)

public String getAttributesOrDefault(String key, String defaultValue)

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;

Parameters
NameDescription
keyString
defaultValueString
Returns
TypeDescription
String

getAttributesOrThrow(String key)

public String getAttributesOrThrow(String key)

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;

Parameter
NameDescription
keyString
Returns
TypeDescription
String

getData()

public ByteString getData()

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

bytes data = 1;

Returns
TypeDescription
ByteString

The data.

getDefaultInstanceForType()

public PubsubMessage getDefaultInstanceForType()
Returns
TypeDescription
PubsubMessage

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
TypeDescription
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
TypeDescription
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
TypeDescription
ByteString

The bytes for messageId.

getMutableAttributes()

public Map<String,String> getMutableAttributes()

Use alternate mutation accessors instead.

Returns
TypeDescription
Map<String,String>

getOrderingKey()

public String getOrderingKey()

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.

string ordering_key = 5;

Returns
TypeDescription
String

The orderingKey.

getOrderingKeyBytes()

public ByteString getOrderingKeyBytes()

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.

string ordering_key = 5;

Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
boolean

Whether the publishTime field is set.

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
TypeDescription
FieldAccessorTable
Overrides

internalGetMapField(int number)

protected MapField internalGetMapField(int number)
Parameter
NameDescription
numberint
Returns
TypeDescription
MapField
Overrides

internalGetMutableMapField(int number)

protected MapField internalGetMutableMapField(int number)
Parameter
NameDescription
numberint
Returns
TypeDescription
MapField
Overrides

isInitialized()

public final boolean isInitialized()
Returns
TypeDescription
boolean
Overrides

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public PubsubMessage.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputCodedInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
PubsubMessage.Builder
Overrides Exceptions
TypeDescription
IOException

mergeFrom(Message other)

public PubsubMessage.Builder mergeFrom(Message other)
Parameter
NameDescription
otherMessage
Returns
TypeDescription
PubsubMessage.Builder
Overrides

mergeFrom(PubsubMessage other)

public PubsubMessage.Builder mergeFrom(PubsubMessage other)
Parameter
NameDescription
otherPubsubMessage
Returns
TypeDescription
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
NameDescription
valueTimestamp
Returns
TypeDescription
PubsubMessage.Builder

mergeUnknownFields(UnknownFieldSet unknownFields)

public final PubsubMessage.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
NameDescription
unknownFieldsUnknownFieldSet
Returns
TypeDescription
PubsubMessage.Builder
Overrides

putAllAttributes(Map<String,String> values)

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

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;

Parameter
NameDescription
valuesMap<String,String>
Returns
TypeDescription
PubsubMessage.Builder

putAttributes(String key, String value)

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

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;

Parameters
NameDescription
keyString
valueString
Returns
TypeDescription
PubsubMessage.Builder

removeAttributes(String key)

public PubsubMessage.Builder removeAttributes(String key)

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;

Parameter
NameDescription
keyString
Returns
TypeDescription
PubsubMessage.Builder

setData(ByteString value)

public PubsubMessage.Builder setData(ByteString value)

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

bytes data = 1;

Parameter
NameDescription
valueByteString

The data to set.

Returns
TypeDescription
PubsubMessage.Builder

This builder for chaining.

setField(Descriptors.FieldDescriptor field, Object value)

public PubsubMessage.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
NameDescription
fieldFieldDescriptor
valueObject
Returns
TypeDescription
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
NameDescription
valueString

The messageId to set.

Returns
TypeDescription
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
NameDescription
valueByteString

The bytes for messageId to set.

Returns
TypeDescription
PubsubMessage.Builder

This builder for chaining.

setOrderingKey(String value)

public PubsubMessage.Builder setOrderingKey(String value)

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.

string ordering_key = 5;

Parameter
NameDescription
valueString

The orderingKey to set.

Returns
TypeDescription
PubsubMessage.Builder

This builder for chaining.

setOrderingKeyBytes(ByteString value)

public PubsubMessage.Builder setOrderingKeyBytes(ByteString value)

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.

string ordering_key = 5;

Parameter
NameDescription
valueByteString

The bytes for orderingKey to set.

Returns
TypeDescription
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
NameDescription
valueTimestamp
Returns
TypeDescription
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
NameDescription
builderForValueBuilder
Returns
TypeDescription
PubsubMessage.Builder

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

public PubsubMessage.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
NameDescription
fieldFieldDescriptor
indexint
valueObject
Returns
TypeDescription
PubsubMessage.Builder
Overrides

setUnknownFields(UnknownFieldSet unknownFields)

public final PubsubMessage.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
NameDescription
unknownFieldsUnknownFieldSet
Returns
TypeDescription
PubsubMessage.Builder
Overrides