views:

634

answers:

1

First of all i will describe current state:
Server consists of several WCF services, hosted in one or several win services on diffirent machines.

  1. Service responsible for recieving data from diffirent devices. Communication with devices is implemented using sockets. Service instance mode - singleton.
  2. Data broker service - responsible for persisting data and sharing in by request. Instance mode - singleton.
  3. Configuration service - responsible for changing configuration database and working with administration console(WPF app, like SSMS). Handles connections from console, subscriber management, etc. Instance mode - singleton.
  4. Client access service - quite the same as above thith management of clients but also notifyes clients of new data, and acts like facade to service bus. And singleton again.
  5. Identity management service - Checks permissions and returns result. Singleton.

All of those services are connected with NServiceBus and i realy like how it works at this moment.

But:
Too many singletons. Mainly because to use servicebus i must have single instance of it afaik. I dunno maybe i can use nservice bus in session mode, but dont know how to handle issue that all of those services will use one queue.

And what if i will have 300+ clients? singleton can become unresponsive..

And i wanted to ask for some critics about all of this and maybe some one could suggest something.

Thanks in advance.
Alexey

+3  A: 

Alexey,

While you should only have one instance of the bus per process, you can put that instance in a globally accessible place (as shown in the AsyncPages sample), and use that from non-singleton objects like web pages and WCF services.

Also, it is probably not appropriate to have all your services using one queue. Without better understanding your situation, I'd give the default recommendation of one queue for each of the services you identified.

Hope that helps.

Udi Dahan
every service has its own queue. Will take a look at async pages sample. Idealy i want services that communicate with external clients to wor in session mode. That would be great.
Alexey Anufriyev
Looked at async pages examle. it is interesting. So if i inject bus object into sessionful service instance, how i can determine that message was targeted to concrete instance? For example we have 2 connected clients. Both have their own sessions. Then they send messages of the same type each. How to determine what service instanse will handle callback?
Alexey Anufriyev
> how i can determine that message was targeted to concrete instance?Alexey - not sure what you're asking. Are you asking about a WCF callback, or an NServiceBus callback?
Udi Dahan
service bus callabck=) sorry for my bad english=) hard to explain sometimes=)
Alexey Anufriyev
NServiceBus will callback to the instance that called:Bus.Send(msg).Register(callback);
Udi Dahan
what if 2 sessions will try to register callbacks for same type of message?
Alexey Anufriyev
Each callback is managed separately by NServiceBus.
Udi Dahan