mercredi 8 avril 2015

Hexagonal Architecture/Ports and Adapter Architecture for Windows Services. Right way?

Flow of Hexagonal Architecture


I have read different sources about Ports & Adapters architecture proposed by Alistair Cockburn and find it apt for my scenario of developing a gateway service application which receives message from multiple sources and process the message and send the message to multiple destinations. Here is my implementation in detail.



  • Currently the source of message is single(JMS Queue)

  • The JMS Port subscribes to the JMS Message Queue and passes it to JMS Adapter which in turn invokes the corresponding message handler.

  • The Message handler in turn calls the business domain layer which is independent of the source or destination of message as proposed by cockburn.

  • The Message handler which has JMS Port,WCF Port,DB Port,TCP Port injected by dependency injection container in turn invokes the JMS Port,TCP Port and WCF Port to publish/send the domain processed message.


I have several key questions/doubts if whether i have deviated from Cockburn's proposed architecture.



  1. Can a single Port handle both inflow/outflow of message(In this case JMS Port). Or is it a good practice to have seperate ports for inflow and outflow of messages.


2.As per the cockburn's article it says


Inbound communication: "As events arrive from the outside world at a port, a technology-specific adapter converts it into a usable procedure call or message and passes it to the application."


Outbound communication: "When the application has something to send out, it sends it out through a port to an adapter, which creates the appropriate signals needed by the receiving technology (human or automated)."


So i have passed on the processed message directly to the port which in turn calls the adapter to transform the message as per the destination requirements.




  1. Can Message Handlers (Application Layer) have the dependency of Ports injected ?




  2. As per the article by Cockburn it says




There will typically be multiple adapters for any one port, for various technologies that may plug into that port.


I can't think of a scenario where mulitple adapters are required for a single port. Can you throw me a scenario so that i can leverage the architecture to the fullest.


Aucun commentaire:

Enregistrer un commentaire