-
Notifications
You must be signed in to change notification settings - Fork 75
/
rabbitmq_producer_configuration.go
37 lines (33 loc) 路 1.17 KB
/
rabbitmq_producer_configuration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package configurations
import (
"reflect"
types2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types"
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/utils"
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/rabbitmq/producer/options"
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/rabbitmq/types"
)
type RabbitMQProducerConfiguration struct {
ProducerMessageType reflect.Type
ExchangeOptions *options.RabbitMQExchangeOptions
RoutingKey string
DeliveryMode uint8
Priority uint8
AppId string
Expiration string
ReplyTo string
ContentEncoding string
}
func NewDefaultRabbitMQProducerConfiguration(
messageType types2.IMessage,
) *RabbitMQProducerConfiguration {
return &RabbitMQProducerConfiguration{
ExchangeOptions: &options.RabbitMQExchangeOptions{
Durable: true,
Type: types.ExchangeTopic,
Name: utils.GetTopicOrExchangeName(messageType),
},
DeliveryMode: 2,
RoutingKey: utils.GetRoutingKey(messageType),
ProducerMessageType: utils.GetMessageBaseReflectType(messageType),
}
}