Consider a single-server queueing system with K job classes, each having its own renewal input process and its own general service time distribution. Further suppose the queue is in heavy traffic, meaning that its traffic intensity parameter is near the critical value of one. A system manager must decide whether or not to accept new jobs as they arrive, and also the order in which to serve jobs that are accepted. The goal is to minimize penalties associated with rejected jobs, subject to upper bound constraints on the throughput times for accepted jobs; both the penalty for rejecting a job and the bound on the throughput time may depend on job class. This problem formulation does not make sense in a conventional queueing model, because throughput times are random variables, but we show that the formulation is meaningful in an asymptotic sense, as one approaches the heavy traffic limit under diffusion scaling. Moreover, using a method developed recently by Bramson and Williams, we prove that a relatively simple dynamic control policy is asymptotically optimal in this framework. Our proposed policy rejects jobs from one particular class when the server's nominal workload is above a threshold value, accepting all other arrivals; and the sequencing rule for accepted jobs is one that maintains near equality of the relative backlogs for different classes, defined in a natural sense.