Browse Source

Merge pull request #6 from doluca/main

publish: message headers added
pull/18/head
Lane Wagner 5 years ago
committed by GitHub
parent
commit
38a273d1d3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      publish.go

+ 9
- 0
publish.go View File

@ -40,6 +40,7 @@ type PublishOptions struct {
ContentType string
// Transient or Persistent
DeliveryMode uint8
Headers Table
}
// WithPublishOptionsExchange returns a function that sets the exchange to publish to
@ -76,6 +77,13 @@ func WithPublishOptionsPersistentDelivery(options *PublishOptions) {
options.DeliveryMode = Persistent
}
// WithPublishOptionsHeaders returns a function that sets message header values, i.e. "msg-id"
func WithPublishOptionsHeaders(headers Table) func(*PublishOptions) {
return func(options *PublishOptions) {
options.Headers = headers
}
}
// Publisher allows you to publish messages safely across an open connection
type Publisher struct {
chManager *channelManager
@ -182,6 +190,7 @@ func (publisher *Publisher) Publish(
options.Mandatory,
options.Immediate,
amqp.Publishing{
Headers: tableToAMQPTable(options.Headers),
ContentType: options.ContentType,
Body: data,
DeliveryMode: options.DeliveryMode,


Loading…
Cancel
Save