Skip to content

Commit

Permalink
print message properties
Browse files Browse the repository at this point in the history
  • Loading branch information
hassansin committed Aug 28, 2017
1 parent 0a0bd8e commit d2742f5
Show file tree
Hide file tree
Showing 108 changed files with 26,125 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@


.PHONY: setup test release
.PHONY: setup test release rabbit

setup:
go get -u github.com/govend/govend
go get -u github.com/goreleaser/goreleaser
govend

rabbit:
docker run --rm -d --name rabbit -p 5672:5672 -p 15672:15672 rabbitmq:3.6.5-management
# make release tag=v0.0.1
release:
git tag -a $(tag) -m $(tag) && git push origin $(tag) && goreleaser
10 changes: 10 additions & 0 deletions cmd/consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package cmd

import (
"fmt"
"reflect"
"strconv"
"strings"

"github.com/oleiade/reflections"
"github.com/spf13/cobra"
"github.com/streadway/amqp"
)
Expand Down Expand Up @@ -122,8 +124,16 @@ Use comma-separated values for binding the same queue with multiple routing keys
fmt.Printf("Queue: %s\n", q.Name)
fmt.Printf("Redelivered: %v\n", msg.Redelivered)
fmt.Printf("Headers: %v\n", msg.Headers)
fmt.Printf("ConsumerTag: %v\n", msg.ConsumerTag)
fmt.Printf("Payload: \n%s\n\n", msg.Body)

fmt.Println("Properties:")
for _, key := range valid_properties {
if val, err := reflections.GetField(msg, key); err == nil && val != reflect.Zero(reflect.TypeOf(val)).Interface() {
fmt.Printf("%s: %q\n", key, val)
}
}

count++
if number != 0 && count >= number {
ch.Close()
Expand Down
1 change: 1 addition & 0 deletions cmd/produce.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ To pass headers and properites, use '--headers' & '--properties' any number of t
returns := ch.NotifyReturn(make(chan amqp.Return, 1))
confirms := ch.NotifyPublish(make(chan amqp.Confirmation, 1))

fmt.Printf("Sending message with Exchange: '%s' and Key: '%s'\n", exchange, routingkey)
if err = ch.Publish(
exchange, // exchange
routingkey, // routing-key
Expand Down
24 changes: 24 additions & 0 deletions vendor/github.com/davecgh/go-spew/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/davecgh/go-spew/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

201 changes: 201 additions & 0 deletions vendor/github.com/davecgh/go-spew/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/github.com/davecgh/go-spew/cov_report.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d2742f5

Please sign in to comment.