Changing Infrastructure to use NSB To Reduce Coupling between applications


(james) #1

Currently our infrastructure consists of multiple applications and multiple back-end databases.

GOALS:

I want to develop a more loosely coupled infrastructure by creating web API’s and messaging to help communicate between multiple applications.

I also want to move business logic out of stored procedures which we currently rely on heavily, and put this logic in services containing NServiceBus handlers. Does this sound sane?

One of the things i am not entirely sure about is if i want an external application to grab information from a database how do i return this information.

process:
External API -> NServicebus WebAPI endpoint -> get information -> return information(Json Response)
-> external API

Is this the process i would use? does NServiceBus allow for this? what are the best practices?

I am graduate developer so please bare with me and correct me if anything i say seams daft!


(Daniel Marbach) #2

Hi jay,

By

One of the things i am not entirely sure about is if i want an external application to grab information from a database how do i return this information.

Do you mean a traditional query?

If it is a query that we are talking about I would not recommend to use messaging. The book Enterprise Integration Patterns, Gregor Hohpe and Bobby Woolf summarizes messaging very well

Use Messaging to transfer packets of data frequently, immediately, reliably, and asynchronously, using customizable formats.

Asynchronous messaging is fundamentally a pragmatic reaction to the problems of distributed systems. Sending a message does not require both systems to be up and ready at the same time. Furthermore, thinking about the communication in an asynchronous manner forces developers to recognize that working with a remote application is slower, which encourages design of components with high cohesion (lots of work locally) and low adhesion (selective work remotely).

With queries though when an external application wants to read some information you want to return the information directly to the caller, so it is not of fire & forget nature which messaging encourages. In those cases, it would be better suited to fetch the data from the database and serialize it to the client directly

Regards
Daniel


(james) #3

Ok, that makes complete sense :slight_smile: thank you!


(Daniel Marbach) #4

Hi Jay,

I’m more than happy to discuss with you further questions on a call if you’d like to dive deeper into messaging and nservicebus. Feel free to ping me at daniel dot marbach at particular dot net if you have further questions that you’d like to discuss in a call

Regards
Daniel


(james) #5

I will defiantly take you up on this offer, Thank you. I will be in touch!