Listens for messages coming from ActivityFired
and SendActivityDigest
subjects
by creating two subscriptions through Stream
method provided by the consumer.
Both subscription are created under the group name activity-ingestion-svc
so that in case of horizontal scaling e
ach message will be randomly balanced to only one of the subscribers
consumer, err := natskit.NewConsumer(natsURL, log)
h1 := func(ctx context.Context, msg *nats.Msg) error {...}
consumer.Stream(ctx, "ActivityFired", "activity-ingestion-svc", h1)
h2 := func(ctx context.Context, msg *nats.Msg) error { ... }
consumer.Stream(ctx, "SendActivityDigest", "activity-ingestion-svc", h2)
Publish messages to ActivityDigest
subject
producer, err := natskit.NewProducer(natsURL, log)
producer.Publish("ActivityDigest", activityDigestMessage)