WCF / ESB architecture?

I worked on creating a set of enterprise services using WCF 4 in my organization and could use some recommendations. The setup / architecture that I have developed so far is similar to a lightweight custom ESB. I have one main โ€œbrokerโ€ service (using wsHttp) that connects to the three basic netTcp services. Both brokers and basic services have a common assembly containing a model, as well as contract interfaces. In the brokerage service, I can choose which operations from the basic services I want to open. The idea is that potentially we can have a core set of services and several different brokers, depending on the needs of the business. We plan to host everything (including netTcp services) in IIS 7.5 using AppFabric and WAS.

So my question is, is such a good practice, and will it scale? These services should be able to process thousands of transactions per day.

I played with routing in WCF 4 instead of the concept of a brokerage service, which I mentioned, however, did not see much value in it, as it simply redirects.

I am also trying to figure out how to optimize the proxies that the brokerage service (provided that this practice is appropriate) is among the main services. Now I just have proxies as private members in the main class of brokers. Example:

private UnderlyingServiceClient _underlyingServiceClient = new UnderlyingServiceClient(); 

I reviewed proxy caching, however, I am concerned that if I encounter an error that the entire proxy server at this point will be erroneous and cannot be reused (unless I catch the error and just do not re-create the instance) .

My goal with these services is to ensure that the client who has consumed them can "enter and exit" as quickly as possible. Quick response request.

Any input / feedback is welcome.

+4
source share
1 answer

If you understand correctly, you have several backends, possibly on separate computers. Then you have one "fontend" service, which basically acts as a proxy server for the backend, but is fully configurable in code. We do this fine tuning from multiple computers in a rack. Our interface is IIS7, the backend is a set of wcf services on multiple machines.

One, will it scale? Well, adding extra processing power to the backend is pretty simple, and writing load balancing code is not that bad either. For us, the problem was that the interface was bogged down, although it acted only as a proxy. In the end, we added a few more front-end computers, โ€œbrokers,โ€ as you call them. It works very well. People suggested using Microsoft ForeFront for automatic load balancing, but I havenโ€™t researched it yet.

Two, do I need to cache proxies? I would say, of course, yes, but that sucks. Sometimes these channels interrupt work. I have a thread that always runs in the background. Every 3 seconds it wakes up, checks all the services of wcf and wcf clients in the application. Any that are mistakenly destroyed and recreated.

check host channels: ...

 while(true) { try{if(MyServiceHost.State!=System.ServiceModel.CommunicationState.Opened) {ReCreate();}} catch{} System.Threading.Thread.Sleep(3000); } 

check client channels: ...

  private static ChannelFactory<IMath> mathClientFactory = new ChannelFactory<IMath>(bindingHttpBin); while(true) { try { if(MyServiceClient.State==System.ServiceModel.CommunicationState.Faulted) { EndpointAddress ea = new EndpointAddress(ub.Uri); ch = WcfDynamicLan.mathClientFactory.CreateChannel(ea); } } catch{} System.Threading.Thread.Sleep(3000); } 

On the client, I not only cache the channel, but also cache the ChannelFactory. This is just for convenience, but in order to make the code for creating a new channel shorter.

0
source

Source: https://habr.com/ru/post/1386411/


All Articles