public SearchRequestPublisher(Boolean bAsync = false) { //initialize connections and channels factory = MQConnectionFactory.getInstance().RabbitMQFactory; connection = factory.CreateConnection(); channel = connection.CreateModel(); //set up consumer event for when message is received consumer = new EventingBasicConsumer(channel); if (bAsync) { //declare rpc queue if not done already channel.QueueDeclare("rpc_async_queue", false, false, false, null); consumer.Received += (model, ea) => ConsumerEventAsync(model, ea); } else { //declare rpc queue if not done already channel.QueueDeclare("rpc_queue", false, false, false, null); consumer.Received += (model, ea) => ConsumerEvent(model, ea); } //declare reply queue replyQueueName = channel.QueueDeclare().QueueName; //set up message properties corrId = Guid.NewGuid().ToString(); props = channel.CreateBasicProperties(); props.ReplyTo = replyQueueName; props.CorrelationId = corrId; }
public SearchRequestPublisher() { //initialize connections factory = MQConnectionFactory.getInstance().RabbitMQFactory; connection = factory.CreateConnection(); channel = connection.CreateModel(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddOptions(); var mqSection = Configuration.GetSection("MessageQueueSettings").Get <ConnectionDetails>(); services.AddSingleton(MQConnectionFactory.GetMessageClient(mqSection)); var connStrings = Configuration.GetSection("ConnectionStrings").GetChildren(); var dictionary = new Dictionary <string, string>(); foreach (var cs in connStrings) { dictionary.Add(cs.Key, cs.Value); } services.AddSingleton <IHttpClient>(new HttpClientWrapper(dictionary)); }