The whole "homosexuality" problem is almost irrelevant here. The OP says that he is uncomfortable with having sex as a duty and that isn't on the table, so it is really irrelevant why. The emperor could be sterile or in a monogamous relationship with a female who for whatever reason can't bear their children, the emperor could be a woman who can't bring a child to term, could be a member of the clergy who has taken a vow of chastity, could be a child doomed to die before maturity, could have a crippling genetic disease, could simply be asexual, etc.

There is no solution to this problem. If they are the only person who carries the bloodline (which is kind of a bad setup in the first place IMO, what would happen if the emperor chokes on a grape and dies before producing an heir?), and for ANY reason they can't produce children, then the bloodline is going to die out.

The only way for this to work is for some magical / technological macguffin comes along that allows them to produce a child without sex or transfer the bloodline to an adoptive heir. There really isn't any other option.