Pregunta

I need some design suggestions if any one could suggest one that would be great.

I implemented a WCF service that reads messages from a queue(MSMQ) on windows server and processes it further.Now I need to read the messages from another queue and process them seperately.I am confused to go with a new service or update the existing service which would do the both readings from different queues parallel.

I am thinking interms of performance which would be the best option to go ?

¿Fue útil?

Solución

You should be able to just have a separate thread for each consumer. Below is the pseudo code. The only things you need to make sure is to signal stop to threads when service is being shut down.

new Thread(WorkerA) { IsBackground = true }.Start();
new Thread(WorkerB) { IsBackground = true }.Start();

void WorkerA() {
   while (true) { /* process queue a */ }
}

void WorkerB() {
   while (true) { /* process queue b */ }
}

Performance should be equivalent when talking about 1 service vs 2 services because it will still be a thread being scheduled by the operating system. As for stability, you could be a little more resilient when splitting the services, but that still shouldn't be too much of an issue, I would expect that the single service approach should be stable enough within each thread.

In the end I would just go for the simplest approach.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top