Reference documentation and code samples for the Cloud Pub/Sub API class Google::Cloud::PubSub::PublishResult.
The result of a publish operation. The message object is available on
#message and will have #message_id assigned by the API.
When the publish operation was successful the result will be marked
#succeeded?. Otherwise, the result will be marked #failed? and the
error raised will be availabe on #error.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Pub/Sub API - Class Google::Cloud::PubSub::PublishResult (v3.0.2)\n\nVersion latestkeyboard_arrow_down\n\n- [3.0.2 (latest)](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-PublishResult)\n- [3.0.1](/ruby/docs/reference/google-cloud-pubsub/3.0.1/Google-Cloud-PubSub-PublishResult)\n- [2.23.0](/ruby/docs/reference/google-cloud-pubsub/2.23.0/Google-Cloud-PubSub-PublishResult)\n- [2.22.0](/ruby/docs/reference/google-cloud-pubsub/2.22.0/Google-Cloud-PubSub-PublishResult)\n- [2.21.0](/ruby/docs/reference/google-cloud-pubsub/2.21.0/Google-Cloud-PubSub-PublishResult)\n- [2.20.0](/ruby/docs/reference/google-cloud-pubsub/2.20.0/Google-Cloud-PubSub-PublishResult)\n- [2.19.0](/ruby/docs/reference/google-cloud-pubsub/2.19.0/Google-Cloud-PubSub-PublishResult)\n- [2.18.1](/ruby/docs/reference/google-cloud-pubsub/2.18.1/Google-Cloud-PubSub-PublishResult)\n- [2.17.0](/ruby/docs/reference/google-cloud-pubsub/2.17.0/Google-Cloud-PubSub-PublishResult)\n- [2.16.0](/ruby/docs/reference/google-cloud-pubsub/2.16.0/Google-Cloud-PubSub-PublishResult)\n- [2.15.5](/ruby/docs/reference/google-cloud-pubsub/2.15.5/Google-Cloud-PubSub-PublishResult)\n- [2.14.0](/ruby/docs/reference/google-cloud-pubsub/2.14.0/Google-Cloud-PubSub-PublishResult)\n- [2.12.1](/ruby/docs/reference/google-cloud-pubsub/2.12.1/Google-Cloud-PubSub-PublishResult)\n- [2.11.0](/ruby/docs/reference/google-cloud-pubsub/2.11.0/Google-Cloud-PubSub-PublishResult)\n- [2.10.0](/ruby/docs/reference/google-cloud-pubsub/2.10.0/Google-Cloud-PubSub-PublishResult)\n- [2.9.2](/ruby/docs/reference/google-cloud-pubsub/2.9.2/Google-Cloud-PubSub-PublishResult) \nReference documentation and code samples for the Cloud Pub/Sub API class Google::Cloud::PubSub::PublishResult.\n\nThe result of a publish operation. The message object is available on\n[#message](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_message_instance_ \"Google::Cloud::PubSub::PublishResult#message (method)\") and will have [#message_id](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_message_id_instance_ \"Google::Cloud::PubSub::PublishResult#message_id (method)\") assigned by the API.\n\n\n\u003cbr /\u003e\n\nWhen the publish operation was successful the result will be marked\n[#succeeded?](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_succeeded__instance_ \"Google::Cloud::PubSub::PublishResult#succeeded? (method)\"). Otherwise, the result will be marked [#failed?](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_failed__instance_ \"Google::Cloud::PubSub::PublishResult#failed? (method)\") and the\nerror raised will be availabe on [#error](/ruby/docs/reference/google-cloud-pubsub/latest/Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_error_instance_ \"Google::Cloud::PubSub::PublishResult#error (method)\"). \n\nInherits\n--------\n\n- Object\n\nMethods\n-------\n\n### #attributes\n\n def attributes()\n\nThe message's attributes.\n\n### #data\n\n def data()\n\nThe message's data.\n\n### #error\n\n def error()\n\nThe error that was raised when published, if any.\n\n### #failed?\n\n def failed?() -\u003e Boolean\n\nWhether the publish request failed. \n**Returns**\n\n- (Boolean)\n\n### #message\n\n def message()\n\n**Aliases**\n\n- [#msg](./Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_msg_instance_) \nThe message.\n\n### #message_id\n\n def message_id()\n\n**Aliases**\n\n- [#msg_id](./Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_msg_id_instance_) \nThe ID of the message, assigned by the server at publication\ntime. Guaranteed to be unique within the topic.\n\n### #msg\n\n def msg()\n\n**Alias Of** : [#message](./Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_message_instance_) \nThe message.\n\n### #msg_id\n\n def msg_id()\n\n**Alias Of** : [#message_id](./Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_message_id_instance_) \nThe ID of the message, assigned by the server at publication\ntime. Guaranteed to be unique within the topic.\n\n### #publish_time\n\n def publish_time()\n\n**Alias Of** : [#published_at](./Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_published_at_instance_) \nThe time at which the message was published.\n\n### #published_at\n\n def published_at()\n\n**Aliases**\n\n- [#publish_time](./Google-Cloud-PubSub-PublishResult#Google__Cloud__PubSub__PublishResult_publish_time_instance_) \nThe time at which the message was published.\n\n### #succeeded?\n\n def succeeded?() -\u003e Boolean\n\nWhether the publish request was successful. \n**Returns**\n\n- (Boolean)"]]