RNSO - A Remote Notifiers,Subjects and Observers Server over DCOM
The Observer Design Pattern helps you to build
applications when a change on a data need to be notified to another of your app.
The Datas are called Subjects, and parts of applications interrested by the
changes is (are) Observers.
Changes are notified from Subjects to Observers
by notifications, throught a Server (called the Manager). Only the manager knows
about the Observers who want to be notified. It maintains the connections called
Subscriptions.
Generally, Observers indicates they want to be notified by a method :
Observer1.Subscribe( pSubject ) ;
Observer2.Subscribe( pSubject ) ;
Subject prevents changes by another method :
Subject.Notify( ..something
) ;
Here, the 2 observers Observer1 and Observer2 will be notified ..
This design pattern is very usefull for GUI applications (MDI..), but this can be used in several other cases. As an example, if you build a DLL to access to a hardware equipment and you’d like to use it on remote Machine, you ‘ll be able with RNSO.
RNSO allows to build client-server applications over DCOM, without knowing about DCOM or the Observer Design Pattern, and is independant of applications. The Server can serve several applications at the same time, even they have no relations.
How does RNSO Work?
Subject1 notifies about changes. The server (RNSO.EXE, is automatically launched by the OS) notify the Observers who subscribed to the subject.
Observers have a sink interface used by server to notify them. This is also a component, with a mailbox. The mailbox is read by a thread of the component. So the server is not blocked by clients.
Datas that a subject can notify are binary. So you can transmit all you want.
Binaries of RNSO
I made several binaries for RNSO :
RNSO.exe
The server
RNSOSupport.DLL
Dll used both by the server and the clients.
RNSOClient.DLL
Dll used to build the observer clients (need also RNSOSupport.DLL). You don't
need of it if you just build a Subject.
The binaries are build with Visual C++ 6.0.
The Sample Application
The sample application shows you:
- how to make a
CDialog as an Observer and a Subject.
- how to use
classes and ready-to-use components .
The following figure shows 2 instances of the application.
1) On the left, we declared the name of the object for
the dialog: Subject1.
2) On the rite, we declare the
dialog as an observer to Subject1.
3) On the left, the
subject notify a change 'My Message'
4) On the
rite, the subscriber received the notification.
You can start several apps and subscribe to 'Subject1'. All of them will be notified. When a subject is going down, subscribers receive a notification.
In my sample, I derived my CDialog from CDialog an from RnsoNotificationRout. This class has 2 virtuals methods. Overload them to handle notifications:
class AFX_EXT_CLASS RnsoNotificationRout
{
public:
RnsoNotificationRout();
virtual ~RnsoNotificationRout();
virtual void OnNotifyNOTIFY(ObserverNotification* pNotification);
virtual void OnNotifyNOTIFY_SUBJECTBROKEN(DWORD dwSubjectID);
};
You aren't obliged to have a dialog or a window to build an Observer or a Subject. You can also make you class just as an Observer, or just a Subject.
This is very simple.
Why to use this framework?
You dont have to maintain subscriptions yourself with lists, arrays.. etc.
You can build interprocess / intermachines apps.

Comments
Problems with distributed applications
Posted by Legacy on 11/25/2002 12:00amOriginally posted by: Vlad
It is a good article. But I have problem trying to run the application on different computers. It works fine on one computer. But when I try to deploy it on different computers - it fails. It run RNSO server on remote computer but after this can not add sink interface (AtlAdvice in ClientSubject project fails).
I'm relatively new in DCOM and could not find what's wrong.
May be somebody know the solution ?
Thank you.
ReplyDCOM Setup
Posted by Legacy on 01/10/2001 12:00amOriginally posted by: Dennis Morales
Hi, the topic is very good and I think it's what I really need but I have problem setting it up using DCOM.
I'm testing it with Windows 2000 Prof and Windows NT 4.0 Server, Is it possible to have the clients in one PC and the RNSO server on the other PC? Why is it that when I do Subscribe and Notify nothing happens, actually the server crashes.... In the OnInitDialog I think the object is successfully created.. otherwise I'll get the error "unable to create object" in French.. right?
Thanks, I'm a newbie to this and I really some pointers on it...
ReplyRelease version
Posted by Legacy on 08/30/2000 12:00amOriginally posted by: Guy creveld
Very nice, i like it.
But it dosn't compile to me at release version.
what do i have to do?
ReplyIt is a good article
Posted by Legacy on 04/25/2000 12:00amOriginally posted by: Xu Xinghai
I need it very much
ReplyVery Nice Indeed
Posted by Legacy on 08/18/1999 12:00amOriginally posted by: Marty Ellis
ReplyVery cool
Posted by Legacy on 11/13/1998 12:00amOriginally posted by: Famory TOURE
This is a very cool. It adds object notification and naming to DCOM.
ReplyWhat about adding support for MS message queues
Posted by Legacy on 11/09/1998 12:00amOriginally posted by: Martin Bohring
If I understand your solution correct, it's not possible to have asynchron observers attached later on and being updated then. Have you thought about using MS message queues for that. Using this new technology it would be possible to create something similar to the CORBA Event Services using DCOM as transport medium.
Reply