incubator-s4-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Banawalikar, Omkar IN BLR SISL" <omkar.banawalikar....@siemens.com>
Subject RE: How to fire events back to client-adpater
Date Thu, 03 May 2012 14:10:34 GMT
I guess the dispatcher.dispatchEvent() method should be called from processEvent() method.
You have not included the processEvent() method.


Omkar Banawalikar

From: Rajeshwar Mitra [mailto:Rajeshwar.Mitra@symphonysv.com]
Sent: Friday, April 27, 2012 6:12 PM
To: s4-user@incubator.apache.org
Subject: How to fire events back to client-adpater

Hi All,

I'm trying to dispatch custom events back to client-adapter where the client- application
will listen to.

My class is as follows,

public class CartListener implements UpdateListener{// Esper CEP Listener

                private StreamSelectingDispatcher dispatcher;



                public StreamSelectingDispatcher getDispatcher() {
                                return dispatcher;
                }



                public void setDispatcher(StreamSelectingDispatcher dispatcher) {
                                this.dispatcher = dispatcher;
                }



                @Override
                public void update(EventBean[] newEvents, EventBean[] oldEvents) {
        EventBean event = newEvents[0];
        String itemList =(String)event.get("cartItemList");
        System.out.println("Cart Item List is " + itemList);
        Logger.getLogger("cart").info("Found matching Cart with items : " + itemList);
                                Recommendation recomend = new Recommendation();
                                recomend.setFlag("Found matching Cart with items : " + itemList);

        dispatcher.dispatchEvent("Recommendation", recomend);// Null pointer Exception occurring
from here.
                }

The spring configuration to set the beans as follows.

<bean id="cartListener" class="com.gsshop.example.listener.CartListener">
                <property name="dispatcher" ref="selectiveDispatchToAdapter"/>
   </bean>
<bean id="selectiveDispatchToAdapter" class="io.s4.dispatcher.StreamSelectingDispatcher">
          <property name="dispatcher" ref="dispatcherToClientAdapters"/>
          <property name="streams">
            <list>
              <value>Recommendation</value>
            </list>
          </property>
  </bean>

When I deploy and run S4 there is no error in initializing the beans. At runtime, the Nullpointer
Exception happens. Dispatcher remains null.

Any help will be useful.

Thanking you,
Rajeshwar Mitra

________________________________
NOTICE TO RECIPIENT: THIS E-MAIL (INCLUDING ANY ATTACHMENTS) IS MEANT FOR ONLY THE INTENDED
RECIPIENT OF THE TRANSMISSION, MAY CONTAIN CONFIDENTIAL INFORMATION, AND IS PROTECTED BY LAW.
IF YOU RECEIVED THIS E-MAIL IN ERROR, PLEASE IMMEDIATELY NOTIFY THE SENDER OF THE ERROR BY
RETURN E-MAIL, DELETE THIS COMMUNICATION AND SHRED ANY ATTACHMENTS. UNAUTHORIZED REVIEW, USE,
DISSEMINATION, DISTRIBUTION, COPYING OR TAKING OF ANY ACTION BASED ON THIS COMMUNICATION IS
STRICTLY PROHIBITED.

Mime
View raw message