MQController
Package: @opra/common
MQController is the runtime class that represents a message-queue controller in an OPRA document. A controller groups related operations that share a set of headers and local data types. You obtain an MQController instance through MQApi or by looking it up from the document.
Inheritance
DocumentElement
└── MQController
Properties
| Property | Type | Description |
|---|---|---|
kind | 'MQController' | Always 'MQController'. |
name | string | Controller name as registered in the API. |
description | string | undefined | Human-readable description. |
headers | MQHeader[] | Headers declared directly on this controller. |
operations | ResponsiveMap<MQOperation> | Operations registered on this controller. |
types | DataTypeMap | Local data types scoped to this controller. |
ctor | Type | undefined | The TypeScript class constructor registered for this controller. |
instance | object | undefined | Resolved controller instance (populated at runtime). |
Methods
findHeader(paramName, location?)
Searches for a header by name on this controller. If not found locally, walks up to the parent MQApi. Returns undefined if the header does not exist at any level.
const header = controller.findHeader('x-correlation-id');
findHeader(paramName: string, location?: string): MQHeader | undefined
toJSON(options?)
Returns a plain OpraSchema.MQController object for schema export.
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.MQController
Obtaining an MQController instance
import { MQApi, MQController } from '@opra/common';
const document = await ApiDocumentFactory.createDocument({ ... });
if (document.api instanceof MQApi) {
const ctrl = document.api.findController('CustomerQueue');
if (ctrl) {
console.log(ctrl.name); // 'CustomerQueue'
console.log(ctrl.headers.length); // number of declared headers
for (const [name, op] of ctrl.operations) {
console.log(name, op.channel);
}
}
}
→ MQApi · MQOperation · MQHeader