Last active
January 5, 2020 13:20
-
-
Save StarpTech/c0fb1b7e67bf90eea034ef9fa9dcc90b to your computer and use it in GitHub Desktop.
Proxy events to stream processors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub, err := sc.Subscribe("eventstore.events", func(m *stan.Msg) { | |
// TODO check if event was already processed | |
stan.PublishAsync("eventstore.events.order-projection", m.Data) | |
stan.PublishAsync("eventstore.events.order-reactor", m.Data) | |
// TODO track event as processed | |
// ack message | |
if err := m.Ack(); err != nil { | |
log.WithFields(eventLogFields).WithFields(r.baseLogFields).WithError(err).Error("ack event") | |
} | |
}, | |
stan.maxInFlight(1), | |
stan.AckWait("30s"), | |
stan.SetManualAckMode(), | |
stan.DurableName(durableName), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment