static void Main(string[] args) { var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null); var consumer = new EventingBasicConsumer(channel); var repository = GetRepository(); consumer.Received += (model, ea) => { var body = ea.Body; var vacancy = (Vacancy)BinaryConverter.ByteArrayToObject(body); repository.AddNew(vacancy); Console.WriteLine(" [x] Received {0}", vacancy); }; channel.BasicConsume(queue: "hello", autoAck: true, consumer: consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } }