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 doesn't have to be further processed because there is the message MSG3 which is newer (receiveTimestamp) and changes the same entity with same "object ID".
.setHeader(AsynchConstants.OBJECT_ID_HEADER, ns.xpath("/cus:setCustomerRequest/cus:customer/cus1:externalCustomerID", String.class))
/** * 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 */ List<ChildMessage> getChildMessages(Message parentMsg, Object body); |
Design of this functionality is flexible because:
Receive asynchronous message
Receive asynchronous messages and storing them in DB:
Hereby accepting an asynchronous message ends when it is persisted in internal database for further processing and OpenHub framework sends confirmation to external system that message was adopted.