It can be rather demoralizing when agents and editors are uninterested in your manuscript. I knew from the start that rejection is the rule rather than the exception. However, knowing something intellectually is very different from accepting it emotionally.
I'm working on developing the emotional callouses that a writer needs to endure the occupational hazard of repeated rejections. I remember reading somewhere that J. K. Rowling received many rejections for her first Harry Potter manuscript. Doing some checking shows that the number may not have been vast. Still, a dozen publishers rejected Harry Potter.
Self-publishing was not such an attractive option when J. K. Rowling was pitching her first novel. Nowadays it is far less expensive to reach readers yourself (although you have to compete with a great many other self-published, as well as traditionally-published, authors). Some very successful and critically-acclaimed books have been self-published in recent years (and one of them even won a Rita Award this year).
So, it's not the end of the world if an author runs out of agents and publishers to pitch.