I want to apply hexagonal architecture to my userManagement
boundedContext
. So I want to define 2 ports (one for UI
, another one for serviceBus
integration, to listen for events from another services).
The question is if I want to implement adapters
for UI port
(I'm not sure it should be called UI port
, basically that's the interfaces where CreateNewUser, BlockUser, CheckIfUserExists
operations live) using different technologies WCF and Owin. How can I add them to my console app?
Let's say I want to implement Soap adapter
using WCF and rest using Owin. In many examples I see that people create separate console applications per driving adapters, ie: MyDDD.UserManagement.Api.Rest.Host
and MyDDD.UserManagement.Api.Soap.Host
. What I want to achieve is one host app and the ability to connect adapters to it somehow. Please share your ideas!
So I want to define 2 ports (one for UI, another one for serviceBus integration, to listen for events from another services).
You missunderstood the concept of port. What you call UI and service bus integration are adapters. They are 2 adapters for the port. They use the port. They call the operations offered by the port. The port is technology agnostic, independent from the delivery mechanism. The port is just an interface offering the use cases of your application.
UI port(I'm not sure it should be called UI port, basically that's the interfaces where CreateNewUser, BlockUser, CheckIfUserExists operations live)
Ports should be named according to their purpose. If the operations are for managing users, I should call it "userManagement". Or if your BC is named that way, call the port just "api" (I prefer a meaningfull name though).
if I want to implement adapters... How can I add them to my console app?
I think you are wrong here. If by console you mean a CLI, then the console is another adapter for the port. You don't add adapters to it.
if I want to implement adapters for UI port using different technologies WCF and Owin. How can I add them to my console app?
I tell you the way I do it: Adapters declare themselves with a name (with a custom annotation). The main component, when bootstraping the whole system, scans for adapters, and select the ones you want for each port by checking their names.
What I want to achieve is one host app and the ability to connect adapters to it somehow.
I do it this way: I have a multi-module project. The hexagon is one module, and every adapter is another module. I have another module named "main" that builds all together and runs the adapters you want. You can put the adapters you want for each port in a properties file for example. That's the way I do it.