0

hoping for some advice on my architecture

Currently I used a layered architecture but somethings are getting a bit complex and was thinking a message bus would be far more useful

I have a controller action called "CreateTeam" on the TeamControler

Which fires of the to TeamService method CreateTeam and then also fires of to the PlayerService method "CreatePlayers".

Which means my TeamController method "CreateTeam" has two responsilibites

But when the user creates a team, I need players to be created also.

So would it be better that CreateTeam, also fires an event TeamCreated which was picked up elsewhere? Giving single responsibility and separating concerns?

Also, I have never used Message bus pattern before so hope im not confusing anyone but is it right that events are raised which the bus picks up and anything listening then gets? So this would be Tell don't ask?

And finally, the listeners on the message bus, could they be web api controllers? Rather then lots of seperate applications? So my PlayerController method with CreatePlayers, could be fired of when CreateTeamEvent is raised?

Luke
  • 1
  • 2
  • I am no expert on architecture, but I can relate to the structure of my main application. Basically, I would imagine the scenario where you are no longer interacting with your main business logic via a controller. Then the intelligence for creating players would rest solely in your Service class. If you don't do this, then a different caller to the Service class would not know what to do. If a new Team must always create new Players, then let the Service do it. Then this means... your message listeners call the Service, rather than trying to get a controller to pick up the messages. – S. Baggy May 04 '15 at 00:02

1 Answers1

0

Somewhere in your system you have to have the knowledge (responsibility) embedded to call your 2 separate functions. The Servicebus could be used to do this but in my experience that would be an overly complex and more difficult to understand resolution.

I would stick with a layer (service class) as suggested by @S. Baggy.

Mikee
  • 1,571
  • 2
  • 14
  • 24