@@ -18,6 +18,7 @@ import {
1818 DeleteBindingResponseDecoder ,
1919 DeleteExchangeResponseDecoder ,
2020 DeleteQueueResponseDecoder ,
21+ GetQueueInfoResponseDecoder ,
2122} from "./response_decoder.js"
2223import { AmqpBinding , Binding , BindingInfo , BindingOptions } from "./binding.js"
2324import { randomUUID } from "crypto"
@@ -35,6 +36,7 @@ const MANAGEMENT_NODE_CONFIGURATION: SenderOptions | ReceiverOptions = {
3536export interface Management {
3637 declareQueue : ( queueName : string , options ?: Partial < QueueOptions > ) => Promise < Queue >
3738 deleteQueue : ( queueName : string ) => Promise < boolean >
39+ getQueueInfo : ( queueName : string ) => Promise < Queue >
3840 declareExchange : ( exchangeName : string , options ?: Partial < ExchangeOptions > ) => Promise < Exchange >
3941 deleteExchange : ( exchangeName : string ) => Promise < boolean >
4042 bind : ( key : string , options : BindingOptions ) => Promise < Binding >
@@ -144,6 +146,30 @@ export class AmqpManagement implements Management {
144146 } )
145147 }
146148
149+ async getQueueInfo ( queueName : string ) : Promise < Queue > {
150+ return new Promise ( ( res , rej ) => {
151+ this . receiverLink . once ( ReceiverEvents . message , ( context : EventContext ) => {
152+ if ( ! context . message ) {
153+ return rej ( new Error ( "Receiver has not received any message" ) )
154+ }
155+
156+ const response = new GetQueueInfoResponseDecoder ( ) . decodeFrom ( context . message , String ( message . message_id ) )
157+ if ( response . status === "error" ) {
158+ return rej ( response . error )
159+ }
160+
161+ return res ( new AmqpQueue ( response . body ) )
162+ } )
163+
164+ const message = new LinkMessageBuilder ( )
165+ . sendTo ( `/${ AmqpEndpoints . Queues } /${ encodeURIComponent ( queueName ) } ` )
166+ . setReplyTo ( ME )
167+ . setAmqpMethod ( AmqpMethods . GET )
168+ . build ( )
169+ this . senderLink . send ( message )
170+ } )
171+ }
172+
147173 async declareExchange ( exchangeName : string , options : Partial < ExchangeOptions > = { } ) : Promise < Exchange > {
148174 const exchangeInfo : ExchangeInfo = {
149175 type : options . type ?? "direct" ,
0 commit comments