示例#1
1
// 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
}
示例#2
0
func NewBroker(rmq *rabbitmq.RabbitMQ, log logging.Logger) *Broker {

	return &Broker{
		rmqConn: rmq.Conn(),
		log:     log,
	}
}
示例#3
0
// 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
}
示例#4
0
func NewController(rmqConn *rabbitmq.RabbitMQ, pubnub *models.PubNub, broker *models.Broker) *Controller {

	return &Controller{
		Pubnub:  pubnub,
		Broker:  broker,
		logger:  runner.MustGetLogger(),
		rmqConn: rmqConn.Conn(),
	}
}
示例#5
0
// 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,
	)
}
示例#6
0
// 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,
	)
}