method GcpPubSubBroker.prototype.request
GcpPubSubBroker.prototype.request<TReq, TRes>(
topic: string,
message: TReq,
options?: RequestOptions
): Promise<TRes>

Sends a request to a topic and awaits a single correlated reply, providing brokered request-reply (RPC) over the message broker.

A responder registered with respond on the same topic returns the reply. The call rejects with a RequestTimeoutError when no reply arrives within options.timeoutMs, and with a RemoteHandlerError when the responder throws.

Request traffic rides a channel derived from topic, disjoint from plain publish/subscribe on that same topic — a pub/sub consumer never observes an RPC request, and vice versa.

Type Parameters

TReq

The request payload type

TRes

The reply payload type

Parameters

topic: string

Destination topic the responder is listening on

message: TReq

The request payload (serialized by the broker adapter)

optional
options: RequestOptions

Reply timeout behavior

Return Type

Promise<TRes>

The reply payload

Usage

import { GcpPubSubBroker } from "messaging-plugin/src/index.ts";