davsclaus opened a new pull request, #29013: URL: https://github.com/apache/camel/pull/29013
Fixes [CAMEL-26184](https://issues.apache.org/jira/browse/CAMEL-26184). All four bugs of the issue were real and are fixed. The new `QuickfixjInOutTest` runs an in-process acceptor and initiator (VM_PIPE), so no external service is needed. ### 1. An InOut consumer replied to every event, and re-sent the Logon recursively **Was:** `QuickfixjConsumer.onExchange` sent a reply when `exchange.hasOut()`. For an InOut exchange the pipeline always copies IN to OUT at the end, so every event was answered with the body the route ended with. Messages the route did not answer were echoed back. The `AdminMessageSent` event of the Logon sent the Logon again, which raised a new event, and so on. With a plain `from("quickfix:...&exchangePattern=InOut").to("mock:x")` route the sessions never log on. **Now:** a reply is sent only for an `AppMessageReceived` event, only when the route set a reply (the body is not the FIX message received, and not null), and only when the exchange did not fail. ### 2. A reply that is not a FIX message failed inside `fromApp` **Was:** the reply was read with `getBody(quickfix.Message.class)`. A `Map` became null, and `Session.send(null)` threw a NullPointerException inside the QuickFIX/J `fromApp` callback. The incoming sequence number was not advanced, so the engine kept asking for the request again and the route ran again each time. **Now:** the reply is converted with `getMandatoryBody`. If that fails, the error goes to the consumer's exception handler (WARN by default) and no reply is sent. The callback completes, so the request counts as received. A null body means no reply. Route failures still go back to QuickFIX/J as before. That is on purpose ("so sequence numbers can be adjusted"). ### 3. An InOut producer without `CorrelationCriteria` never got a reply **Was:** `MessageCorrelator.getReply` added a rule with a null predicate. `onEvent` then threw a NullPointerException for every engine event until the exchange timed out. **Now:** `getReply` throws an `IllegalArgumentException` that names the property, before the rule is added and before the message is sent. The doc already said the criteria is required. I chose to fail fast rather than treat the exchange as InOnly, so a requester that expects a reply does not silently get its own request back as the body. ### 4. A producer body that is not a FIX message failed with a bare NPE **Now:** `getMandatoryBody(Message.class)`, so the `InvalidPayloadException` names the body type. ### Tests - `QuickfixjInOutTest` (new, in-process acceptor and initiator): - an unanswered message is not echoed back; - Map and null replies are not sent, and each request is routed once; - the producer gets the matching reply; - an InOut producer without criteria fails before sending; - a Map producer body names its type. On main all 5 fail: the Logon loop means the sessions never log on. With only the consumer fix applied, the two producer tests still fail (`ExchangeTimedOutException` and `NullPointerException`). - `QuickfixjConsumerTest`: 4 new unit tests: other events are not answered, the received message is not sent back, a null reply is not sent, and a Map reply goes to the exception handler. Two of them fail on main. - `QuickfixjProducerCorrelationCleanupTest`: a request without criteria fails before it is sent and leaves no rule. Fails on main. - `QuickfixjProducerTest`: the mock now stubs `getMandatoryBody`. - Module: 59 tests, all pass with `-Psourcecheck`. ### Docs and generated files - Component doc: the InOut consumer and producer sections describe the new rules. - `@BodyTypes` `consumerReply` and `producerOut` updated. The component JSON and doc copy in camel-catalog are regenerated. No yaml-dsl-validator test references quickfix. - Upgrade guide 4.24: new `camel-quickfix` section. ### Not changed - A route that changes the received `quickfix.Message` in place and expects it to be sent back no longer gets a reply. The route must set a new message as the reply. - A reply that QuickFIX/J cannot send (`CannotSendException`, unknown session) still fails the exchange as before. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
