Asynchronous message processing:
"direct:SERVICE_OPERATION_OUTROUTE"
where SERVICE is value from enum interface implementation ServiceEnum, OPERATION is name of operation and OUTROUTE is const AbstractBasicRoute#OUT_ROUTE_SUFFIX. Service and operation names are values configured via AsynchRouteBuilder, see also AsynchConstants.SERVICE_HEADER and AsynchConstants.OPERATION_HEADER
Implementation of route for asynchronous message is the same as synchronous message but there are some differences which must be followed:
MSG1 setCustomer(externalCustomerId=5) OK MSG2 setCustomer(externalCustomerId=5) PARTLY_FAILED MSG3 setCustomer(externalCustomerId=5) OK
Message MSG2 must not be further processed because there exists the message MSG3, which is newer and changes the same entity with same "object ID".
.setHeader(AsynchConstants.OBJECT_ID_HEADER, ns.xpath("/cus:setCustomerRequest/cus:customer/cus1:externalCustomerID", String.class))
if a message is too complex to process as altogether it is recommended (appropriate solution) to split into small child messages (partial messages). Main (parent) message will be successfully processed when all her child messages will be also successfully processed. Conversely, if any partial message will in FAILED status, then the main message will in FAILED status.
/** * Gets child messages for next processing. * Order of child messages in the list determines order of first synchronous processing. * * @param parentMsg the parent message * @param body the exchange body * @return list of child messages */ protected abstract List<ChildMessage> getChildMessages(Message parentMsg, Object body); |
Implementation of MessageSplitter must be as Spring bean to resolve next dependencies:
Design of this functionality is so flexible because:
Receive asynchronous message
Receive asynchronous messages and storing them to DB:
Hereby accepting an asynchronous message ends, is persisted in internal database for further processing and OpenHub framework sends confirmation to external system that message was adopted.