Last active
August 27, 2015 13:33
-
-
Save xogeny/ad2e563637d868b9c54d to your computer and use it in GitHub Desktop.
Publishing a message that exceeds the maximum gnatsd payload size
This file contains hidden or 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
package main | |
import ( | |
"log" | |
gs "github.com/apcera/gnatsd/server" | |
"github.com/apcera/nats" | |
) | |
func msg(n int) []byte { | |
ret := []byte{} | |
for i := 0; i < n; i++ { | |
ret = append(ret, byte(i)) | |
} | |
log.Printf("Created a message of length: %d", len(ret)) | |
return ret | |
} | |
func main() { | |
nc, err := nats.Connect(nats.DefaultURL) | |
if err != nil { | |
log.Printf("Unable to connect: %v", err) | |
return | |
} | |
subj := "Request" | |
reply := "Reply" | |
badMsg := nats.Msg{Subject: subj, Reply: reply, Data: msg(gs.MAX_PAYLOAD_SIZE * 2)} | |
err = nc.PublishMsg(&badMsg) | |
log.Printf("err = %v", err) | |
log.Printf("closed = %v", nc.IsClosed()) | |
log.Printf("LastError = %v", nc.LastError()) | |
goodMsg := nats.Msg{Subject: subj, Reply: reply, Data: msg(100)} | |
err = nc.PublishMsg(&goodMsg) | |
log.Printf("err = %v", err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment