Transfer of messages between connected applications and systems plays primary role in Enterprise Application Integration as its the sole purpose that integration platform serves sitting in between the entire network of connected applications. When it comes to the pattern of communication to be followed; there are several choices that can be considered to meet the business needs in efficient and desired manner. In this post, I will briefly talk about such messaging patterns that are applicable to Enterprise application integration.
Synchronous message communication:
Synchronous communication is a messaging pattern in which the communicating parties transfer message with each other in one session in a blocking mode where the producer of the message waits for the response/acknowledgement from the message consumer before closing the session. Request-Response based communication between the parties is based on synchronous messaging pattern. There are dozens of scenarios where this mode of communication becomes a preferred choice for integration solutions.
When to use synchronous messaging for Enterprise Application Integration solutions?
As described above, request and response are shared between the producer and the consumer in the same session in synchronous mode, this approach is more suitable for scenarios where real-time interaction with minimal delays is needed between the applications/systems. Synchronous transfer of messages between the systems is required when subsequent actions are dependent on the response received for the previous message transferred and further actions need to be performed in sequential manner.
Example Scenario for Synchronous Messaging:
Consider a scenario where a customer is using bank’s ATM machine to withdraw some cash. In this scenario, ATM machine needs to interact with the back-end system in synchronous manner to check the available balance so that the customer is informed in the same session if he is eligible to withdraw the money or not. For this type of scenarios involving real-time communication, synchronous message communication pattern is used.
Below image shows how synchronous message communication takes place between two communicating parties:
Asynchronous message communication:
Asynchronous message communication is just opposite to the synchronous one as in this mode of communication, producer doesn’t wait for the consumer to respond back in the same session and there is no blocking in the session. Producing application/system just closes the session after sending the message for the consumer application. Consumer application can handle and process the request in its own convenience and can take any further action required (e.g. sending a delayed response back to the producer through another interface exposed by the producer or just perform any additional actions in some other system). Fire & forget, Publish Subscribe are considered asynchronous messaging modes widely used in integration platforms.
When to use Asynchronous messaging for integration solutions?
Asynchronous communication mode is preferred in scenarios where large/bulk data needs to be transferred between the communicating systems and there is no need of real-time responses. Since Asynchronous messaging is non-blocking by nature, larger amount of data can be transferred in parallel sessions using this mode.
Example Scenario for Asynchronous Messaging:
Consider a scenario where a ERP system needs to broadcast/publish some information so that any interested parties can subscribe to that and get the updates. In this scenario, ERP system will just publish the data to a messaging layer destination (e.g. EMS Topic) and it will not wait for any responses from the parties consuming/subscribing to those messages. For this type of scenarios, asynchronous communication is a preferred choice.
Below image shows how Asynchronous message communication takes place between two communicating parties: