Last active
October 14, 2017 09:51
-
-
Save shijuvar/e9d48c9302d58e23db5d250df2814408 to your computer and use it in GitHub Desktop.
Publish messages asynchronously to NATS Streaming Server
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
ackHandler := func(ackedNuid string, err error) { | |
if err != nil { | |
log.Printf("Error publishing message id %s: %v\n", ackedNuid, err.Error()) | |
} else { | |
log.Printf("Received ACK for message id %s\n", ackedNuid) | |
} | |
} | |
channel := event.Channel | |
eventMsg := []byte(event.EventData) | |
// Publish message on subject (channel) | |
nuid, err := sc.PublishAsync(channel, eventMs, ackHandler) | |
if err != nil { | |
log.Printf("Error publishing message %s: %v\n", nuid, err.Error()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment