Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow vhost specification in the environment.

  • Loading branch information...
commit 32a84ebca099acfb8584e158736511fea2ffe623 1 parent ffc8512
Guy M. Allard authored
4 ack_11/ack_11.go
View
@@ -41,12 +41,12 @@ func main() {
}
fmt.Println(exampid + "dial complete ...")
ch := stompngo.Headers{"accept-version", "1.1",
- "host", h}
+ "host", sngecomm.Vhost()}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(e) // Handle this ......
}
- fmt.Println(exampid + "stomp connect complete ...", conn.Protocol())
+ fmt.Println(exampid+"stomp connect complete ...", conn.Protocol())
// Setup Headers ...
u := stompngo.Uuid() // Use package convenience function for unique ID
6 ack_12/ack_12.go
View
@@ -41,12 +41,12 @@ func main() {
}
fmt.Println(exampid + "dial complete ...")
ch := stompngo.Headers{"accept-version", "1.2",
- "host", h}
+ "host", sngecomm.Vhost()}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(e) // Handle this ......
}
- fmt.Println(exampid + "stomp connect complete ...", conn.Protocol())
+ fmt.Println(exampid+"stomp connect complete ...", conn.Protocol())
// Setup Headers ...
u := stompngo.Uuid() // Use package convenience function for unique ID
@@ -102,7 +102,7 @@ func main() {
log.Fatalln("Bad subscription header")
}
// ACK the message just received.
- fmt.Println(exampid + "will ACK:", m.Message.Headers.Value("ack"))
+ fmt.Println(exampid+"will ACK:", m.Message.Headers.Value("ack"))
ah := stompngo.Headers{"id", m.Message.Headers.Value("ack")} // 1.2 ACK headers
fmt.Println(exampid, "ACK Headers", ah)
e := conn.Ack(ah)
2  connect_11/connect_11.go
View
@@ -54,7 +54,7 @@ func main() {
// for the connection, but in this example is the same.
//
ch := stompngo.Headers{"accept-version", "1.1",
- "host", h}
+ "host", Vhost()}
// Get a stomp connection. Parameters are:
// a) the opened net connection
2  connect_ssl_11/connect_ssl_11.go
View
@@ -64,7 +64,7 @@ func main() {
// pairs. The stompngo package implements them using a string slice.
//
ch := stompngo.Headers{"accept-version", "1.1",
- "host", h}
+ "host", Vhost()}
// Get a stomp connection. Parameters are:
// a) the opened net connection
2  receive_11/receive_11.go
View
@@ -41,7 +41,7 @@ func main() {
}
fmt.Println(exampid + "dial complete ...")
ch := stompngo.Headers{"accept-version", "1.1",
- "host", h}
+ "host", sngecomm.Vhost()}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(e) // Handle this ......
2  receive_12/receive_12.go
View
@@ -41,7 +41,7 @@ func main() {
}
fmt.Println(exampid + "dial complete ...")
ch := stompngo.Headers{"accept-version", "1.2",
- "host", h}
+ "host", sngecomm.Vhost()}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(e) // Handle this ......
4 send_11/send_11.go
View
@@ -42,12 +42,12 @@ func main() {
fmt.Println(exampid + "dial complete ...")
ch := stompngo.Headers{"accept-version", "1.1",
- "host", h}
+ "host", sngecomm.Vhost()}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(e) // Handle this ......
}
- fmt.Println(exampid + "stomp connect complete ...", conn.Protocol())
+ fmt.Println(exampid+"stomp connect complete ...", conn.Protocol())
// *NOTE* your application functionaltiy goes here!
// Sending to a 1.1 broker is usally _exactly_ like sending to a 1.0 broker.
4 send_12/send_12.go
View
@@ -42,12 +42,12 @@ func main() {
fmt.Println(exampid + "dial complete ...")
ch := stompngo.Headers{"accept-version", "1.2",
- "host", h}
+ "host", sngecomm.Vhost()}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(e) // Handle this ......
}
- fmt.Println(exampid + "stomp connect complete ...", conn.Protocol())
+ fmt.Println(exampid+"stomp connect complete ...", conn.Protocol())
// *NOTE* your application functionaltiy goes here!
// Sending to a 1.2 broker is usally _exactly_ like sending to a 1.0 broker.
9 sngecomm/sngecomm.go
View
@@ -150,3 +150,12 @@ func SetMAXPROCS() bool {
}
return true
}
+
+// Virtual Host Name to use
+func Vhost() string {
+ d := os.Getenv("STOMP_VHOST")
+ if d == "" {
+ return "localhost"
+ }
+ return d
+}
4 srmgor_11/srmgor_11.go
View
@@ -161,7 +161,7 @@ func startSenders(qn int) {
}
// Stomp connect, 1.1
- ch := stompngo.Headers{"host", h, "accept-version", "1.1"}
+ ch := stompngo.Headers{"host", sngecomm.Vhost(), "accept-version", "1.1"}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(exampid, "startSenders stompconnect error", e, qn) // Handle this ......
@@ -200,7 +200,7 @@ func startReceivers(qn int) {
if e != nil {
log.Fatalln(exampid, "startReceivers nectonnr:", e, qn) // Handle this ......
}
- ch := stompngo.Headers{"host", "localhost", "accept-version", "1.1"}
+ ch := stompngo.Headers{"host", sngecomm.Vhost(), "accept-version", "1.1"}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln("startReceivers stompconnectr:", e, qn) // Handle this ......
4 srmgor_11c/srmgor_11c.go
View
@@ -148,7 +148,7 @@ func runReceiver(qnum int) {
fmt.Println(exampid, "recv network local", n.LocalAddr().String(), qnum)
fmt.Println(exampid, "recv network remote", n.RemoteAddr().String(), qnum)
// Stomp connect, 1.1
- ch := stompngo.Headers{"host", h, "accept-version", "1.1"}
+ ch := stompngo.Headers{"host", sngecomm.Vhost(), "accept-version", "1.1"}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(exampid, "recv stompconnect:", qnum, e) // Handle this ......
@@ -186,7 +186,7 @@ func runSender(qnum int) {
fmt.Println(exampid, "send network local", n.LocalAddr().String(), qnum)
fmt.Println(exampid, "send network remote", n.RemoteAddr().String(), qnum)
// Stomp connect, 1.1
- ch := stompngo.Headers{"host", h, "accept-version", "1.1"}
+ ch := stompngo.Headers{"host", sngecomm.Vhost(), "accept-version", "1.1"}
conn, e := stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(exampid, "send stompconnect:", qnum, e) // Handle this ......
4 srmgor_11s/srmgor_11s.go
View
@@ -168,7 +168,7 @@ func startReceivers(qn int) {
fmt.Println(exampid, "startReceivers starts", qn)
c := sngecomm.Nmsgs() // get message count
- fmt.Printf(exampid, "startReceivers message count:", c, qn)
+ fmt.Println(exampid, "startReceivers message count:", c, qn)
for i := 1; i <= qn; i++ { // all queues
wgrecv.Add(1)
go receiver(i, c)
@@ -205,7 +205,7 @@ func main() {
log.Fatalln("main dial error", e) // Handle this ......
}
// Stomp connect, 1.1
- ch := stompngo.Headers{"host", h, "accept-version", "1.1"}
+ ch := stompngo.Headers{"host", sngecomm.Vhost(), "accept-version", "1.1"}
conn, e = stompngo.Connect(n, ch)
if e != nil {
log.Fatalln(exampid, "main connect error", e) // Handle this ......
Please sign in to comment.
Something went wrong with that request. Please try again.