protected async Task <TMessage> wait_for_message_in_queue <TMessage>( string queueName, Func <TMessage, bool> condition) where TMessage : class { TMessage expectedMessage = null; await wait_for_passed_condition_or_throw_after_timeout(() => { var rawMessage = _rabbitMqQueue.ReadRawMessageFromQueue(queueName); if (rawMessage == null) { return(false); } expectedMessage = JsonConvert.DeserializeObject <MassTransitDefaultMessage <TMessage> >(rawMessage).Message; return(condition(expectedMessage)); }, checkingIntervalInMilliseconds : 1000, retryCount : 100, conditionNotMetErrorMessage : $"Condition failed: message that meets the requirements has not been found in Queue: {queueName}"); return(expectedMessage); }