Skip to main content

MQOperationResponse

Package: @opra/common

MQOperationResponse describes the outgoing message produced by an MQOperation. It declares the response channel, payload type, optional key type, and any response-specific headers.


Inheritance

DocumentElement
└── MQOperationResponse

Properties

PropertyTypeDescription
channelstring | undefinedResponse channel or topic. undefined means the response goes to the same channel as the request.
descriptionstring | undefinedHuman-readable description of the response.
typeDataTypeData type of the response payload. Defaults to 'any' when not explicitly declared.
keyTypeDataType | undefinedOptional data type for the response message key.
headersMQHeader[]Headers declared on the response.
designTypeType | undefinedTypeScript constructor from design:type metadata.
keyDesignTypeType | undefinedTypeScript constructor for the key type from metadata.

Methods

findHeader(paramName)

Searches for a header by name on this response. Returns undefined if not found.

const header = response.findHeader('x-reply-to');
findHeader(paramName: string): MQHeader | undefined

toJSON(options?)

Returns a plain OpraSchema.MQOperationResponse object for schema export.

toJSON(options?: ApiDocument.ExportOptions): OpraSchema.MQOperationResponse

Accessing a response descriptor

MQOperationResponse is always accessed through its parent operation — it is not retrieved directly from the document.

import { MQApi } from '@opra/common';

const document = await ApiDocumentFactory.createDocument({ ... });

if (document.api instanceof MQApi) {
const op = document.api.findOperation('CustomerQueue', 'processOrder');

if (op) {
const { response } = op;
console.log(response.channel); // reply channel, or undefined
console.log(response.type.name); // payload type name
console.log(response.headers); // MQHeader[]
}
}

MQOperation · MQHeader