Skip to content
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,20 @@ func main() {
25
25
failOnError (err , "Failed to open a channel" )
26
26
defer ch .Close ()
27
27
28
+ q , err := ch .QueueDeclare (
29
+ "task_queue" , // name
30
+ true , // durable
31
+ false , // delete when unused
32
+ false , // exclusive
33
+ false , // no-wait
34
+ nil , // arguments
35
+ )
36
+ failOnError (err , "Failed to declare a queue" )
37
+
28
38
body := bodyFrom (os .Args )
29
39
err = ch .Publish (
30
40
"" , // exchange
31
- "task_queue" , // routing key
41
+ q . Name , // routing key
32
42
false , // mandatory
33
43
false ,
34
44
amqp.Publishing {
@@ -37,6 +47,7 @@ func main() {
37
47
Body : []byte (body ),
38
48
})
39
49
failOnError (err , "Failed to publish a message" )
50
+ log .Printf (" [x] Sent %s" , body )
40
51
}
41
52
42
53
func bodyFrom (args []string ) string {
You can’t perform that action at this time.
0 commit comments