Apache Camel .when() Statement Only works half of the time

120 views Asked by At

I have a .choice() statement with multiple .when() cases. However I upload the same file everytime that has MsgFmtVerNr=2 and sometimes it goes to otherwise and sometimes it goes through .when().xpath("/UpsBas/MsgHdr/MsgFmtVerNr = '2'"). I have no idea why this statement is only working half of the time. Is there some reason why it would skip directly to .otherwise() statement? Thanks for the help in advanced.

 .choice()
                .when(body().startsWith(constant("A")))
                    .setHeader(MsgHdr.EVENT_CODE, simple(ErrorCodesLocal.UNSOLICITEDMSG_GIC_BSIS))
                    .beanRef("fromGICRoute", "setMessageHeadersForUnsolicitedMessage(*)")
                    .beanRef("logging", "debug(*, 'Messsage from " + FromGicSourceQueue + " is a unsolicited message')")
                    .multicast().parallelProcessing()
                        .to("direct:unsolicitedMessageToBoss", "direct:unsolicitedMessageToCmods", "direct:unsolicitedMessageToIsps")
                    .endChoice()
                .when(body().contains("<RtgPfl"))
                    .to(RATING_PROFILE_DESTINATION_QUEUE)
                .when().xpath("/UpsBas/MsgHdr/MsgFmtVerNr = '2'")//body().contains("<MsgFmtVerNr>2<"))
                    .to("direct:cv2")
                .otherwise()
                    .to("direct:commercialInvoice")
1

There are 1 answers

0
Connor Blair On

I found the problem for those of you have come across similar issues. I had two bundles linked to the same queue on my server so one file upload would go, correct bundle while other would go to incorrect bundle.