Either the airline or the travel agency (if your trip is through them) can apply for your visa before you start your journey. Although, travel agencies have to apply for the visa for you through the airline.