1. #1
    Sencha User kousikraj's Avatar
    Join Date
    Mar 2010
    Location
    Chennai, India
    Posts
    12
    Vote Rating
    0
    kousikraj is on a distinguished road

      0  

    Default Message Driven Framework for decoupling Portlets / Modules

    Message Driven Framework for decoupling Portlets / Modules


    Consider dashboard environment. The portlets that are loaded in dashboard may be based on ACL data. Lets go by a scenario to understand this problem better.
    Scenario: We need to create a dashboard where we have a button in tool bar of dashboard. On click of that we need to reload data of portlets. In that case, what we shall do is this,

    Optimal Solution: I hope we all are aware about Producer and Consumer problem. Where consumer will be subscribing to an interested topic and producer will be producing messages to that topic. Yes, its a JMS kind of implementation we have to do to decouple the portlets / any system. This strategy can be used widely for any of your systems based on its demands. I used this methodology for alteast 2 of the products I designed so far.
    Example of Implementation: For our example I used ExtJS 4.1 based portlets. I picked the portlets example of ExtJS library and then implemented a Message Driven Framework for UI (MDF-UI) and solved the question I put in above block. This implementation totally decoupled the portlets and even my other modules where all my events are published as topics and interested subscriber portlets will respond based on the topic and message.
    Note: You need to know few things about ExtJS to understand this example easily
    MDF-UI Blocks:

    Above is the representation of components used to create MDF-UI in ExtJS.
    Logger: is used to printing any messages in to browser console.
    Constants: is a directory used to maintain all TOPICS
    Manager: is a Lookup Index where we can use it for storing any components object to it. It is not used in this framework directly, but still thought of sharing it. You can use this to register all UI components loaded in the system.
    NotifierMap: is extension of Ext.util.MixedCollection where I have implementation for how to use it to easily manage all registered Producers and Subscriber informations.
    NotificationManager: is the brain of this framework where we use this to register / de-register producers and subscribers along with the topic.
    IPublishedMessage: can be used as Mixin where it is used to fetch messages for specified topic
    INotifier: is a Mixin where it is abstract implementation of Notifier.
    INotificationLsnr: is a Mixin where it is abstract implementation of Notification Listener.
    AbstractMessenger: is a sample implementation of MDA-UI
    How it works:
    Once the UI / Portlet compoent is loaded the initComponent method will be called Ext. There, I am subscribing the same object by calling NotificationManger via INotificationLsnr mixin with the relevant topic. Like wise, any notifier buttons or components will have INotifier mixin with the topics. So, whenever there is an event, the notifiers will send a message to the NotificationManger which in turn will iteratively call the notified methods of all Subscribers with the message.
    Download Source: You can download the sample code here or you can visit here to look at the working demo. Codes are very simple and self explanatory. You can look at them and then post me if you need any clarity on that. To set up your environment, simply download the source code and extract to your htdocs / webapp folder of your server and call http://localhost/works/extjs/mda/index.html. You should see the app in action.
    Learning Framework: You should open /works/extjs/mda/ux/messaging folder to see Ext.ux.messaging.* components.
    (Warning: If your browser is not loading the app, please try refreshing it once. I am still working to solve the Ext.Loader issues. )

    Feel free to download and use this framework. I would be more than glad to explain this more if you someone is looking for
    Kousik Rajendran,
    Software Architect, Sphata Systems.
    http://kousikraj.wordpress.com

  2. #2
    Sencha User
    Join Date
    Jun 2012
    Posts
    21
    Vote Rating
    1
    catalinux1907 is on a distinguished road

      0  

    Default


    To understand more of the benefits of your implemenation can you tell me how is different than using a message bus where you fire events and your portlets will have a listner for that event?

  3. #3
    Sencha User kousikraj's Avatar
    Join Date
    Mar 2010
    Location
    Chennai, India
    Posts
    12
    Vote Rating
    0
    kousikraj is on a distinguished road

      0  

    Default


    Ya, it is a similar implementation of Message Bus Architecture. But, this is very simple and light in its implementation. If we really see Enterprise Service Bus architecture, that has lot of implementations where any application can access the data published by lot of means like RMI, SOAP, and so .. But in this implementation, it is a very simple library that helps you to make your ExtJS application ready for Messaging service. At the same time, Since we ExtJS developers started developing large Javascript applications, I wanted to share the library that I created to decouple my application.

    And we should understand that this library is not just for portals, this works even with other modules of ExtJS by simply extending AbstractMessenger or using Mixins of INotificationLsnr. I used this library entirely in my product development for any sorts of communication between modules or components.

    I hope I clarified you, or else please let me know.
    Kousik Rajendran,
    Software Architect, Sphata Systems.
    http://kousikraj.wordpress.com

  4. #4
    Sencha User
    Join Date
    Jun 2012
    Posts
    21
    Vote Rating
    1
    catalinux1907 is on a distinguished road

      0  

    Default


    I was not talking about enterprise service bus. I was talking about having an observale object on which you can listen for events and also for these events. Can you make a comparision of benefits.

Thread Participants: 1

Tags for this Thread