Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Robles committed Jul 19, 2018
1 parent 9e3f322 commit eae03a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 6 additions & 0 deletions channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ func createChannel(conn *amqp.Connection) (*amqp.Channel, error) {
return channel, nil
}
}

func CloseChannel(channel *amqp.Channel) {

channel.Close()

}
16 changes: 5 additions & 11 deletions producer.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package conejo

import (
"errors"
//"errors"
"github.com/streadway/amqp"
"log"
)

func Publish(conn *amqp.Connection, queue Queue, exchange Exchange, body string) error {
Expand All @@ -12,7 +13,7 @@ func Publish(conn *amqp.Connection, queue Queue, exchange Exchange, body string)
return err
}
channel.Confirm(false)
ack, nack := channel.NotifyConfirm(make(chan uint64, 1), make(chan uint64, 1))
//ack, nack := channel.NotifyConfirm(make(chan uint64, 1), make(chan uint64, 1))

err = declareExchange(exchange, channel)
if err != nil {
Expand Down Expand Up @@ -51,18 +52,11 @@ func Publish(conn *amqp.Connection, queue Queue, exchange Exchange, body string)
); err != nil {
return err
} else {

select {
case <-ack:
return nil
case <-nack:
err = errors.New("Message not acknowledged")
return err
}
log.Println("CONEJO: Channel closed")
channel.Close()
}
}
}
}
defer channel.Close()
return nil
}

0 comments on commit eae03a0

Please sign in to comment.