< Back
Publish-GcpsMessage
Post
NAME Publish-GcpsMessage
SYNOPSIS
Publishes one or more PubSub messages to a topic.
SYNTAX
Publish-GcpsMessage [-Project <string>] [-Topic] <string> [-Data <string>] [-Attributes <Hashtable>]
[<CommonParameters>]
Publish-GcpsMessage [-Project <string>] [-Topic] <string> -Message <PubsubMessage[]> [<CommonParameters>]
DESCRIPTION
Publishes one or more PubSub messages to a topic. Will raise errors if the topic does not exist. The cmdlet will
search for the topic in the default project if -Project is not used. To publish more than one message, use
-Message parameter with an array of messages constructed from New-GcpsMessage. Otherwise, use -Data and -Attribute
parameters to publish a single message.
PARAMETERS
-Project <string>
The project to check for topic. If not set via PowerShell parameter processing, will default to the Cloud
SDK's DefaultProject property.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Topic <string>
The topic to which the messages will be published.
Required? true
Position? 0
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Data <string>
The data message that will be published.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Attributes <Hashtable>
Attributes of the message that will be published.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <PubsubMessage[]>
Messages to be published. Use this parameter to publish one or more messages.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
---------- EXAMPLE 1 ----------
PS C:\\> Publish-GcpsTopic -Topic "my-topic" -Data "This is a test." -Attributes @{"key"="value"}
This command publishes a message with the specified data and attribute to topic "my-topic" in the default project.
---------- EXAMPLE 2 ----------
PS C:\\> $message1 = New-GcpsMessage -Data "my-data"
PS C:\\> $message2 = New-GcpsMessage -Data "my-data2" -Attributes @{"key"="test"}
PS C:\\> Publish-GcpsTopic -Topic "my-topic" -Message $message1, $message2 -Project "my-project"
This command publishes 2 messages to topic "my-topic" in the project "my-project".
RELATED LINKS
[Publishing Messages to a Topic] (https://cloud.google.com/pubsub/docs/pu ... to-a-topic)
SYNOPSIS
Publishes one or more PubSub messages to a topic.
SYNTAX
Publish-GcpsMessage [-Project <string>] [-Topic] <string> [-Data <string>] [-Attributes <Hashtable>]
[<CommonParameters>]
Publish-GcpsMessage [-Project <string>] [-Topic] <string> -Message <PubsubMessage[]> [<CommonParameters>]
DESCRIPTION
Publishes one or more PubSub messages to a topic. Will raise errors if the topic does not exist. The cmdlet will
search for the topic in the default project if -Project is not used. To publish more than one message, use
-Message parameter with an array of messages constructed from New-GcpsMessage. Otherwise, use -Data and -Attribute
parameters to publish a single message.
PARAMETERS
-Project <string>
The project to check for topic. If not set via PowerShell parameter processing, will default to the Cloud
SDK's DefaultProject property.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Topic <string>
The topic to which the messages will be published.
Required? true
Position? 0
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Data <string>
The data message that will be published.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Attributes <Hashtable>
Attributes of the message that will be published.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <PubsubMessage[]>
Messages to be published. Use this parameter to publish one or more messages.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
---------- EXAMPLE 1 ----------
PS C:\\> Publish-GcpsTopic -Topic "my-topic" -Data "This is a test." -Attributes @{"key"="value"}
This command publishes a message with the specified data and attribute to topic "my-topic" in the default project.
---------- EXAMPLE 2 ----------
PS C:\\> $message1 = New-GcpsMessage -Data "my-data"
PS C:\\> $message2 = New-GcpsMessage -Data "my-data2" -Attributes @{"key"="test"}
PS C:\\> Publish-GcpsTopic -Topic "my-topic" -Message $message1, $message2 -Project "my-project"
This command publishes 2 messages to topic "my-topic" in the project "my-project".
RELATED LINKS
[Publishing Messages to a Topic] (https://cloud.google.com/pubsub/docs/pu ... to-a-topic)