# Interface PubsubMessageOrBuilder (1.151.0)

1.151.0 (latest) 1.150.1 1.149.0 1.148.0 1.147.0 1.145.0 1.143.1 1.142.0 1.141.5 1.140.2 1.139.4 1.138.0 1.137.1 1.136.1 1.135.0 1.134.2 1.133.1 1.132.2 1.131.0 1.130.0 1.129.6 1.127.3 1.126.6 1.125.13 1.123.18 1.122.2 1.121.1 1.120.24 1.119.1 1.118.0 1.117.0 1.116.4 1.115.5

    public interface PubsubMessageOrBuilder extends MessageOrBuilder

## Implements

[MessageOrBuilder](https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageOrBuilder.html)

## Methods

### containsAttributes(String key)

    public abstract 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getAttributes() (deprecated)

    public abstract Map<String,String> getAttributes()

Use [#getAttributesMap()](https://docs.cloud.google.com/java/docs/reference/google-cloud-pubsub/latest/com.google.pubsub.v1.PubsubMessageOrBuilder#com_google_pubsub_v1_PubsubMessageOrBuilder_getAttributesMap__) instead.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |   |

### getAttributesCount()

    public abstract 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** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getAttributesMap()

    public abstract 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** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |   |

### getAttributesOrDefault(String key, String defaultValue)

    public abstract 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `defaultValue` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getAttributesOrThrow(String key)

    public abstract 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getData()

    public abstract 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** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` | The data. |

### getMessageId()

    public abstract 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** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The messageId. |

### getMessageIdBytes()

    public abstract 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** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` | The bytes for messageId. |

### getOrderingKey()

    public abstract 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 `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 [(.google.api.field_behavior) = OPTIONAL];`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | The orderingKey. |

### getOrderingKeyBytes()

    public abstract 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 `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 [(.google.api.field_behavior) = OPTIONAL];`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.ByteString.html` | The bytes for orderingKey. |

### getPublishTime()

    public abstract 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** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Timestamp.html` | The publishTime. |

### getPublishTimeOrBuilder()

    public abstract 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** |
| `https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.TimestampOrBuilder.html` |   |

### hasPublishTime()

    public abstract 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** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | Whether the publishTime field is set. |