Skip to content

How can I implement NATS MESSAGE-ID? #1439

Discussion options

You must be logged in to vote

By default FastStream are use Nats-Core instead of Nats-Jetstream, for enable JS you must pass stream parameter to your subscriber.
Minimal reproducible example:

import json
import uuid

from faststream import FastStream, Logger
from faststream.nats import NatsBroker, JStream, NatsMessage

broker = NatsBroker()
app = FastStream(broker)

CHANNEL_NAME = "telegram.billing"
publisher = broker.publisher(CHANNEL_NAME)


@broker.subscriber(CHANNEL_NAME, stream=JStream(name="stream_name"), durable="durable_name")
async def handler(msg: NatsMessage, logger: Logger):
    """
    handler.
    """
    logger.info(msg)
    await msg.ack()


@app.after_startup
async def test_send():
    """
    test send.

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@Muhammadali-Akbarov
Comment options

@Muhammadali-Akbarov
Comment options

@Muhammadali-Akbarov
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Muhammadali-Akbarov
Comment options

Answer selected by Lancetnik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants