Skip to main content

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

PropertyTypeDescription
kind'MQController'Always 'MQController'.
namestringController name as registered in the API.
descriptionstring | undefinedHuman-readable description.
headersMQHeader[]Headers declared directly on this controller.
operationsResponsiveMap<MQOperation>Operations registered on this controller.
typesDataTypeMapLocal data types scoped to this controller.
ctorType | undefinedThe TypeScript class constructor registered for this controller.
instanceobject | undefinedResolved 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