Class PubsubMessage

  • All Implemented Interfaces:
    com.google.protobuf.Message, com.google.protobuf.MessageLite, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, PubsubMessageOrBuilder, Serializable

    public final class PubsubMessage
    extends com.google.protobuf.GeneratedMessageV3
    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](https://cloud.google.com/pubsub/docs/reference/libraries) for
     more information. See [quotas and limits]
     (https://cloud.google.com/pubsub/quotas) for more information about message
     limits.
     
    Protobuf type google.pubsub.v1.PubsubMessage
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  PubsubMessage.Builder
      A message that is published by publishers and consumed by subscribers.
      • Nested classes/interfaces inherited from class com.google.protobuf.GeneratedMessageV3

        com.google.protobuf.GeneratedMessageV3.BuilderParent, com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageT extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>,​BuilderT extends com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageT,​BuilderT>>, com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>>, com.google.protobuf.GeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>>, com.google.protobuf.GeneratedMessageV3.FieldAccessorTable, com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter
      • Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite

        com.google.protobuf.AbstractMessageLite.InternalOneOfEnum
    • Method Detail

      • newInstance

        protected Object newInstance​(com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused)
        Overrides:
        newInstance in class com.google.protobuf.GeneratedMessageV3
      • getDescriptor

        public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
      • internalGetMapField

        protected com.google.protobuf.MapField internalGetMapField​(int number)
        Overrides:
        internalGetMapField in class com.google.protobuf.GeneratedMessageV3
      • internalGetFieldAccessorTable

        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
        Specified by:
        internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3
      • getData

        public com.google.protobuf.ByteString getData()
         The message data field. If this field is empty, the message must contain
         at least one attribute.
         
        bytes data = 1;
        Specified by:
        getData in interface PubsubMessageOrBuilder
        Returns:
        The data.
      • getAttributesCount

        public int getAttributesCount()
        Description copied from interface: PubsubMessageOrBuilder
         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;
        Specified by:
        getAttributesCount in interface PubsubMessageOrBuilder
      • containsAttributes

        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;
        Specified by:
        containsAttributes in interface PubsubMessageOrBuilder
      • 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;
        Specified by:
        getAttributesMap in interface PubsubMessageOrBuilder
      • getAttributesOrDefault

        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;
        Specified by:
        getAttributesOrDefault in interface PubsubMessageOrBuilder
      • getAttributesOrThrow

        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;
        Specified by:
        getAttributesOrThrow in interface PubsubMessageOrBuilder
      • 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;
        Specified by:
        getMessageId in interface PubsubMessageOrBuilder
        Returns:
        The messageId.
      • getMessageIdBytes

        public com.google.protobuf.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;
        Specified by:
        getMessageIdBytes in interface PubsubMessageOrBuilder
        Returns:
        The bytes for messageId.
      • 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;
        Specified by:
        hasPublishTime in interface PubsubMessageOrBuilder
        Returns:
        Whether the publishTime field is set.
      • getPublishTime

        public com.google.protobuf.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;
        Specified by:
        getPublishTime in interface PubsubMessageOrBuilder
        Returns:
        The publishTime.
      • getPublishTimeOrBuilder

        public com.google.protobuf.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;
        Specified by:
        getPublishTimeOrBuilder in interface PubsubMessageOrBuilder
      • 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 `PubsubMessage`s published in a given `PublishRequest`
         must specify the same `ordering_key` value.
         For more information, see [ordering
         messages](https://cloud.google.com/pubsub/docs/ordering).
         
        string ordering_key = 5;
        Specified by:
        getOrderingKey in interface PubsubMessageOrBuilder
        Returns:
        The orderingKey.
      • getOrderingKeyBytes

        public com.google.protobuf.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 `PubsubMessage`s published in a given `PublishRequest`
         must specify the same `ordering_key` value.
         For more information, see [ordering
         messages](https://cloud.google.com/pubsub/docs/ordering).
         
        string ordering_key = 5;
        Specified by:
        getOrderingKeyBytes in interface PubsubMessageOrBuilder
        Returns:
        The bytes for orderingKey.
      • isInitialized

        public final boolean isInitialized()
        Specified by:
        isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
        Overrides:
        isInitialized in class com.google.protobuf.GeneratedMessageV3
      • writeTo

        public void writeTo​(com.google.protobuf.CodedOutputStream output)
                     throws IOException
        Specified by:
        writeTo in interface com.google.protobuf.MessageLite
        Overrides:
        writeTo in class com.google.protobuf.GeneratedMessageV3
        Throws:
        IOException
      • getSerializedSize

        public int getSerializedSize()
        Specified by:
        getSerializedSize in interface com.google.protobuf.MessageLite
        Overrides:
        getSerializedSize in class com.google.protobuf.GeneratedMessageV3
      • equals

        public boolean equals​(Object obj)
        Specified by:
        equals in interface com.google.protobuf.Message
        Overrides:
        equals in class com.google.protobuf.AbstractMessage
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface com.google.protobuf.Message
        Overrides:
        hashCode in class com.google.protobuf.AbstractMessage
      • parseFrom

        public static PubsubMessage parseFrom​(ByteBuffer data)
                                       throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static PubsubMessage parseFrom​(ByteBuffer data,
                                              com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                       throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static PubsubMessage parseFrom​(com.google.protobuf.ByteString data)
                                       throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static PubsubMessage parseFrom​(com.google.protobuf.ByteString data,
                                              com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                       throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static PubsubMessage parseFrom​(byte[] data)
                                       throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static PubsubMessage parseFrom​(byte[] data,
                                              com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                       throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static PubsubMessage parseFrom​(com.google.protobuf.CodedInputStream input,
                                              com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                       throws IOException
        Throws:
        IOException
      • newBuilderForType

        public PubsubMessage.Builder newBuilderForType()
        Specified by:
        newBuilderForType in interface com.google.protobuf.Message
        Specified by:
        newBuilderForType in interface com.google.protobuf.MessageLite
      • toBuilder

        public PubsubMessage.Builder toBuilder()
        Specified by:
        toBuilder in interface com.google.protobuf.Message
        Specified by:
        toBuilder in interface com.google.protobuf.MessageLite
      • newBuilderForType

        protected PubsubMessage.Builder newBuilderForType​(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)
        Specified by:
        newBuilderForType in class com.google.protobuf.GeneratedMessageV3
      • getDefaultInstance

        public static PubsubMessage getDefaultInstance()
      • parser

        public static com.google.protobuf.Parser<PubsubMessage> parser()
      • getParserForType

        public com.google.protobuf.Parser<PubsubMessage> getParserForType()
        Specified by:
        getParserForType in interface com.google.protobuf.Message
        Specified by:
        getParserForType in interface com.google.protobuf.MessageLite
        Overrides:
        getParserForType in class com.google.protobuf.GeneratedMessageV3
      • getDefaultInstanceForType

        public PubsubMessage getDefaultInstanceForType()
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuilder
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilder