Skip to content

RPC over IBM MQ

FastStream supports blocking request/reply over IBM MQ using a temporary reply queue created from a model queue.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
from faststream import FastStream

from faststream_mq import MQBroker

broker = MQBroker(queue_manager="QM1")
app = FastStream(broker)


@broker.subscriber("rpc.queue")
async def handle(msg: str) -> str:
    return f"processed:{msg}"


@app.after_startup
async def make_request() -> None:
    response = await broker.request("ping", "rpc.queue")
    assert await response.decode() == "processed:ping"

How it works

  • the request message is published to the destination queue
  • FastStream creates a dynamic reply queue for the request
  • the response is matched using MQ-native MsgId -> CorrelId

Caller-managed reply_to routing is not part of the current IBM MQ request API.