@@ -3,13 +3,14 @@ package main
33import (
44 "context"
55 "encoding/json"
6+ "flag"
67 "fmt"
78 "log"
89 "time"
910
1011 "github.com/golang-queue/queue"
1112 "github.com/golang-queue/queue/core"
12- "github.com/golang-queue/rabbitmq"
13+ rabbitmq "github.com/golang-queue/rabbitmq"
1314)
1415
1516type job struct {
@@ -24,15 +25,28 @@ func (j *job) Bytes() []byte {
2425 return b
2526}
2627
28+ var (
29+ uri = flag .String ("uri" , "amqp://guest:guest@localhost:5672/" , "AMQP URI" )
30+ exchange = flag .String ("exchange" , "test-exchange" , "Durable, non-auto-deleted AMQP exchange name" )
31+ exchangeType = flag .String ("exchange-type" , "direct" , "Exchange type - direct|fanout|topic|x-custom" )
32+ q = flag .String ("queue" , "test-queue" , "Ephemeral AMQP queue name" )
33+ bindingKey = flag .String ("key" , "test-key" , "AMQP binding key" )
34+ )
35+
36+ func init () {
37+ flag .Parse ()
38+ }
39+
2740func main () {
2841 taskN := 100
2942 rets := make (chan string , taskN )
3043
3144 // define the worker
3245 w := rabbitmq .NewWorker (
33- rabbitmq .WithQueue ("sample_worker" ),
34- rabbitmq .WithExchangeName ("sample_worker" ),
35- rabbitmq .WithRoutingKey ("sample_worker" ),
46+ rabbitmq .WithAddr (* uri ),
47+ rabbitmq .WithQueue (* q ),
48+ rabbitmq .WithExchangeName (* exchange ),
49+ rabbitmq .WithRoutingKey (* bindingKey ),
3650 rabbitmq .WithRunFunc (func (ctx context.Context , m core.QueuedMessage ) error {
3751 var v * job
3852 if err := json .Unmarshal (m .Bytes (), & v ); err != nil {
0 commit comments