Today I just received the decision of my paper from a journal. The paper was submitted last December and my paper is kind of long (about 40 pages), so I think it's reasonable to take such a long time to receive the decision. Unfortunately, the paper was rejected. And I only received a very short report from a single referee (normally this journal requires two referees) saying that the same result of Prof. B using almost exactly same technique was proved in another paper which was published in another journal, journal A. Therefore the referee decided to reject my paper. So I try to look at this paper from journal A. What was surprising to me is that I have submitted my paper to journal A before I submitted my paper to the present journal and was rejected by journal A. Journal A thinks that the result of Prof. B is good which deserved publication in the journal. However, my paper was rejected. When I look at the submission date of the paper of Prof. B to journal A, I find that I submitted my paper to journal A before Prof. B submitted his paper. What is more surprising to me is that I check the decision letter of my paper from journal A, it seems to me that they even didn't send my paper to the referee to read it, and the paper was rejected within 3 weeks.
Now it seems to me that it's very difficult to get my paper published. So here are questions: Have you ever experienced this? If yes, what did you do to get your paper published? Or did you just give up? Actually I just got my PhD few years ago, and I think maybe that's one of the reason my paper haven't been treated seriously when I submitted to journal A. Any suggestions would be appreciated. Thanks!