How to interact with multiple external system by Restful API

Hello everyone, I am developing a system using Moqui and need to communicate with 3 to 4 external systems. These systems communicate via Restful APIs,and each type of external system has multiple endpoints, The endpoint url should be configurable. I want to ensure that all communications between them are recorded and traceable, when there is a temporary error, I need the message delivery to automatically retry several times. I am considering whether to use SystemMessage for system interactions or to use Service[type=“remote-rest”]. It seems that with SystemMessage, after sending a message, it does not provide the response content from the target API, which is not convenient for interaction. On the other hand, Service[type=“remote-rest”] does return results. I am wondering if SystemMessage is not intended for request-response interactions like mine.

1 Like

The SystemMessage functionality was designed primarily for async communication where a response comes back some time later (even an acknowledge response like an EDI X12 997). It can certainly be used for messaging with a synchronous response, like in most REST API replies.

For multiple remote systems with multiple endpoints the design of the data model is to have one SystemMessageRemote record per remote system, and then one SystemMessageType record per message type, or in a REST API context per endpoint using the sendPath field for the path to the endpoint.

About the response not being saved: which services are you using? In general for SystemMessage functionality the response is saved in a separate SystemMessage record, which references the message it is a response to (if known, usually is even in async messages with a reference ID for the original message, which is the systemMessageId for messages originating in Moqui). If some particular service isn’t doing this it may not have been implemented and needs to be added. I’ll look into if you send over more detail about which services you are using, and any other detail you think might be relevant.

In the send#ProducedSystemMessage and send#SystemMessageRest services, it appears that the response from the remote system is not being saved. I believe this is due to the fact that, as you mentioned, the system message was primarily designed for asynchronous communication. In the case of a synchronous API call, the response serves as the acknowledgment reply.

I reviewed the third party external system’s API, It contains both synchronous and asynchronous communications. It seems I need a synchronous version send#SystemMessageRestSync service.