// createConsumer creates a new amqp consumer func (l *Consumer) createConsumer(rmq *rabbitmq.RabbitMQ) (*rabbitmq.Consumer, error) { exchange := rabbitmq.Exchange{ Name: l.SourceExchangeName, Type: "fanout", Durable: true, } queue := rabbitmq.Queue{ Name: fmt.Sprintf("%s:WorkerQueue", l.WorkerName), Durable: true, } binding := rabbitmq.BindingOptions{ RoutingKey: "", } consumerOptions := rabbitmq.ConsumerOptions{ Tag: fmt.Sprintf("%sWorkerConsumer", l.WorkerName), } consumer, err := rmq.NewConsumer(exchange, queue, binding, consumerOptions) if err != nil { return nil, err } return consumer, nil }
func NewBroker(rmq *rabbitmq.RabbitMQ, log logging.Logger) *Broker { return &Broker{ rmqConn: rmq.Conn(), log: log, } }
// New Creates a new controller for realtime package func New(rmq *rabbitmq.RabbitMQ, log logging.Logger) *Controller { ffc := &Controller{ log: log, rmqConn: rmq.Conn(), } return ffc }
func NewController(rmqConn *rabbitmq.RabbitMQ, pubnub *models.PubNub, broker *models.Broker) *Controller { return &Controller{ Pubnub: pubnub, Broker: broker, logger: runner.MustGetLogger(), rmqConn: rmqConn.Conn(), } }
// createAMQPPublisher creates an AMQPPublisher func (p *Producer) createAMQPPublisher(mq *rabbitmq.RabbitMQ) (*rabbitmq.Producer, error) { // create connection properties exchange := rabbitmq.Exchange{ Name: p.ExchangeName, } publishingOptions := rabbitmq.PublishingOptions{ Tag: p.Tag, RoutingKey: p.RoutingKey, Immediate: false, } return mq.NewProducer( exchange, rabbitmq.Queue{}, publishingOptions, ) }
// createMaintenancePublisher creates a new maintenance queue for storing // errored messages in a queue for later processing func (l *Consumer) createMaintenancePublisher(rmq *rabbitmq.RabbitMQ) (*rabbitmq.Producer, error) { exchange := rabbitmq.Exchange{ Name: "", } publishingOptions := rabbitmq.PublishingOptions{ Tag: fmt.Sprintf("%sWorkerConsumer", l.WorkerName), Immediate: false, } return rmq.NewProducer( exchange, rabbitmq.Queue{ Name: "BrokerMaintenanceQueue", Durable: true, }, publishingOptions, ) }