Motivated by transplant applications, we study a bipartite matching queue with multiclass customers and multitype resources. Customers may change their classes or abandon the system while waiting in queue, and they may decline the offered resource units which results in matching failure. We are interested in designing efficient instantaneous matching policies that allocate resources upon arrival to waiting customers. Our objective is bicriteria and formulated as a cost functional that linearly combines the long-run average expected reward due to successful matches and the long-run average expected cost from customer waiting and abandonment. We first develop a stability condition on the class change and abandonment rates, which requires at least one customer queue with abandonment and that any queue without abandonment have a class transition path to a queue with abandonment. Under this condition, we construct a simple linear program, referred to as the fluid control problem (FCP), which serves as a lower bound for the original stochastic control problem under any admissible policy. We then propose a randomized matching policy based on the solution of the FCP and show that the proposed policy is asymptotically optimal under both the long-run average and ergodic cost criteria. In addition, we apply our method to study two X matching models with two customer classes and two resource types to provide insights on how the class change and matching failure impact the optimal policies.