المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : MSMQ Receiving messages Help!!!



C# Programming
01-06-2010, 04:30 AM
Hi,
I have recently faced a problem, which i am unable to solve. Anyone can guide me please.

Scenario:
I am using MSMQ to communicate between many programs running concurrently...

Programs:
Dedicated TCP/IP server - Windows service
Dedicated Serial Server - Windows service
Dedicated listening Data Processor server - Windows service
Server Manager - Winform App

Message queues:
Data Queue
Command Queue
Admin Queue

I have two communication server listening and sending data to remote clients and data processor. Raw and Processed data are communicated through messages from servers to winform app through data processor. There are two classes named (Event receiver, Event reporter), which each running program subscribes too to communicate between each other. The reporting side is simple containing commands only to send messages. The problem lies in the design of event receiver class.

Its a single classes initializing three receiving(not peeking) events on three message queues. Whereby then it distributes received messages, by using many custom events.

Problem.
Currently declared events as static as they are too be used by many programs running in different projects (i.e the server service project , server manager winform project). The Event reporter, and receiver are in a class library.
What i want is a design pattern for the event receiver class. Which houses MSMQ object initialization and events generated by receiving messages on queue asynchronously, + custom delegates/ events for reporting these messages to different programs in different projects(who subscribe to the static event in this class).
Currently i initialized the Class in the main method of service project, every thing works perfectly there. But nothing happens if i initialize the same class in winform project, which is also dumb work from me as receiving event for message queues now occurs twice in memory as there are now two objects for the class. i.e. May be message is already taken by one class from the queue.

Finally i want a solution in the same design pattern whereby all programs running in different projects are able to to subscribe to same event receiver classes housing receiving events on MSMQ's and custom events , may be static or not?

Help pleasee
i am really stuck!!!!