Skip to content

Commit

Permalink
rabbitmq: modify producer
Browse files Browse the repository at this point in the history
  • Loading branch information
romberli committed Dec 13, 2023
1 parent dc32a06 commit a508110
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions middleware/rabbitmq/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ func (p *Producer) BuildMessageWithExpiration(contentType, message string, expir

// PublishMessage publishes a json message to an exchange
func (p *Producer) PublishJSON(message string) error {
if p.exchange == constant.EmptyString {
return errors.Errorf("Producer.PublishJSON: exchange is empty")
}
if p.key == constant.EmptyString {
return errors.Errorf("Producer.PublishJSON: key is empty")
}

return p.publishWithContext(context.Background(), p.exchange, p.key, p.BuildMessage(constant.DefaultJSONContentType, message))
}

Expand Down

0 comments on commit a508110

Please sign in to comment.