|
This[^] looks like a pretty good checklist of things to work through to resolve your problem.
|
|
|
|
|
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!!!!
|
|
|
|
|
If you don't want the WinForm app to steal data from the data processor then why would you reuse the same class to read data? It sounds like you need another communications method to make the data processor and manager app talk with each other.
faheemnadeem wrote: 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?
I don't understand what that means. It doesn't matter if classes are in the same project or not, if a class is instantiated in two different processes then having static members won't make the two instances share members.
|
|
|
|
|
Hi,
Thank you for replying!!!
You misunderstood my point...
Look everything i told u about above has to communicate with each other, in full duplex mode. i.e.
Servers (service) ---- Data processor (service) ---- Manager (winform)
The manager issues some commands and has the ability to display received data from remote clients, passing through the above mentioned process.
The channel for message transfer is MSMQ which each program is listening to through the event receiver class(class library) and communicating with each other by sending messages through event reporter class(class library). AS message queue structure,
1. Admin_queue
2. Command_queue
3. Data_queue
Event receiver just has a receive event, it takes out message from queue and then reports the relevant data/Command through custom events, which an outside program subscribes to, thus allowing multiple data transfer for multiple number of programs.
The issue was, all these are in different project + i need a design pattern for receiver class.
I need to initialize message queue receive events in that class, + distribute the received message using events.
If i create an new object of the class, for each program to able to subscribe to its events, it would negate the point of receive event for msmq as that can only happen once.
I need a way to solve this issue
|
|
|
|
|
Each program needs its own instance of the receiver class and their own MSMQ for receiving messages. When you initialize the receiver you tell it what should Q to listen to and when you initialize the sender you tell it what Q the data processor is listening to. In the processor you'll need one listener and multiple senders, one for each client. That's how you get two way comms between components.
faheemnadeem wrote: i need a design pattern for receiver class
It's not all that complicated. You just listen for messages in the queue and raise an event when it receives one. If you want a fancy name for it try message endpoint[^].
|
|
|
|
|
Hey thanx buddy for a reply!!!
Still my point remains where it was before
you want me to have a queue for each program
That method i have already implemented, works like a charm for everything.
What i wanted, sorry if i was not clear before, was a single queue for everything.
Many programs pumping messages in, many apps listening situation
Messages are identified by the label, in which i have added a lot of stuff to identify msg content, sender, receiver blah blah
Problem was i had a service project and a winform project.
A single class( the event receiver class ) was written to connect to that single queue and distribute data to every program (service or winform)
the class used a receive event for receiving messages from queue.
I had to declare an object of that class to initialize the connection to msg_Queue, even though the events could be made static and used without initialization.
I initialized the class object once in my service project, works like a charm there.
But in order to use that class in the winform project, i had to have an object of that class there to. but that would totally undermine the receive event in the class(cant have two receive events :P). So thats was my only problem!!!
I have tried peeking but writing that code was complex, (it worked though) but there were random multiple peeks operation and it used much more CPU usage than required.
I have currently done another solution where by i have made 2 queues, one for presentation layer and one for communication layer and 2 event receiver classes. They are working perfectly, but i am still looking for a single queue solution...
P.s. If somehow i can combine the windows service project(housing TCP/Server(service), Serial server(service), Data processor(service)) and winform project into one project, then only one event receiver will be used with only one object for interaction. Is that possible.
I am declaring the class object in the main. as nothing rest is required from that objects (all events are static).
Thnx bro!!!
|
|
|
|
|
faheemnadeem wrote: i am still looking for a single queue solution
Why? There's nothing wrong with having more than one Q and it makes it easier to avoid the situation that you're encountering.
Like you said, the problem with having only one Q is keeping track of which process is supposed to remove messages from it. You tried the easiest solution that I can think of - include the receiver in the label, have every process peek at the message and then based on that the proper receiver will know that it is supposed to be the one to remove it.
faheemnadeem wrote: that code was complex
You're absolutely right! It's much easier to have one dedicated Q for each app, or for you at least one per layer.
faheemnadeem wrote: Is that possible
No. A windows service by definition does not have a user interface so the manager application will need to be a separate process. The only way to combine then would be to add everything into the winfoms app which would probably undermine the reason that you're using a service to begin with .
|
|
|
|
|
:p
thanks for discussing my problemo!!!
I agree with all re points!!!
I am sticking with the situation where i have 2 queues for presentation and communication layer, I will need another event receiver class, that makes it separate for the two projects, thus simplifying everything, with a little more code...
Thanks again!!!
P.s. By the way i am an electronics engineer not a software one, so my jargon on technical terms is a bit low...
Just programming for my Ground control station for a helium powered autonomous airship.
bye
|
|
|
|
|
Glad to help. Good Luck!
|
|
|
|
|
Hi All,
I have a problem with a serialport component ...
In a form, for read from a serial port I write:
Load
{
serialPort1.Close();
serialPort1.NewLine = "\r\n";
serialPort1.PortName = "COM18"; // GPS COM
serialPort1.Open();
}
in the dataReceived event, the app stopped with this error: cross-thread not true...
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
textBox1.Text = serialPort1.ReadLine(); //error line
}
Why error on thread-safe? Help me please (with example).
Many thanks.
Alex
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:13am.
|
|
|
|
|
Perfect!
Thanks.
Alex
|
|
|
|
|
|
thanks Luc ... rich documentations ...
Alex
|
|
|
|
|
you're welcome.
|
|
|
|
|
hi everyone,
how can we do that window minimizing and maximizing at fixed position in java Script like this site?
http://examples.adobe.com/flex3/devnet/dashboard/main.html
is it possible like this?
can u give me sites like that in java script?
Thank u in advance.
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:13am.
|
|
|
|
|
yes,but i did nt get javascript forum,
can u tell me that functionality?
|
|
|
|
|
I need to display a digital book in ritchtextbox and the same time i like to link the topics. I have the list of the chapters and page number i want to jump at the position in the ritchbox when i click on a chapter or a page number from the list.
Thanks in advance
Suheb Ahmad
New Delhi INDIA
|
|
|
|
|
If I understand you correctly you can use RichTextBox.SelectionStart[^] property. It allows you to move to char indicated by this property.
Hope that helps
|
|
|
|
|
SuhebAhamd wrote: I need to display a digital book in ritchtextbox and the same time i like to link the topics.
Display a picture at that position, and create a hyperlink to it. Creating a hyperlink is described here[^].
SuhebAhamd wrote: i want to jump at the position in the ritchbox when i click on a chapter or a page number from the list.
Embed the pagenumber as a parameter into the hyperlink. Once you have the pagenumber, you can jump
I are Troll
|
|
|
|
|
Hi ,
What is the difference between Activator.CreateInstance and new operator
thanks in advance,
Azeez.
|
|
|
|
|
The former allows you to determine, at runtime, the object to be instantiated, while the latter requires that you know that information at design time.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Hello........
I have a problem of printing High resolution image to a spesific sized pages.
I want it to fit in the page.After scaling down the image based on destination sizes(paper sizes),
I am able to fit the image to a page but the quality of the image is not good.
Is there any solution for this????
|
|
|
|
|
Determine the resolution of the printout beforehand, calculate the number of pixels wide and tall, then resize the image using a custom resizing technique (there are quite a few out there). Some sharpen, some blur, some average pixels, some just take the nearest pixel. If you resize the image so it prints out in the native resolution of the printer, then it won't have to do the shoddy resizing (probably nearest pixel) and you'll get the type of resizing you specifically code for.
|
|
|
|