How to send message to client?

Hello, I'm newbie in J2EE. I have a client (e.g. GUI class) which have to "connect" to EJB and start further processing when others 3 clients also connect to this EJB. It's not a problem to obtain reference to EJB and connect to it, but I don't know how to send some message from EJB to client.
I've tried to implement it with events, but it not works. Is it possible to use event for this? Are there any patterns to solve this class of problems? Please, help!
Below fragments of my code for events:
GamesListFrame.java
      try
         title.setText("text");
         tablesManager = getHome().create();
         tablesManager.addStartGameListener(this);
         tablesManager.generateEvent();
      } catch ...
}and TablesManagerBean.java
    * @ejb.interface-method
    *     view-type="remote"
   public void generateEvent()
      EventQueue q = Toolkit.getDefaultToolkit().getSystemEventQueue();
      StartGameEvent event = new StartGameEvent(this);
      q.postEvent(event);     
    * @ejb.interface-method
    *     view-type="remote"
   public void addStartGameListener(StartGameListener listener)
      listenerList.add(StartGameListener.class, listener);
   public void processEvent(AWTEvent event)
      if (event instanceof StartGameEvent)
         EventListener[] listeners = listenerList.getListeners(StartGameListener.class);
         for (int i=0; i<listeners.length; i++)
            ((StartGameListener)listeners).GameStarted((StartGameEvent)event);
else
super.processEvent(event);

Before you make any call form client to server check that sever is available. This is easily done by intorudciing an rmi method that will return true e.g m_sever.isAvalable(); if server is availbel you will get ture if not then you will get an RMI Excpetion which you then trap and attemp to reconnect to the server (NAming.lookup() ) .. if several attempts fail then assume server is down.
When a client dies it throws an excpetion on the sErver :
java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read
     at java.net.SocketInputStream.socketRead0(Native Method)
     at java.net.SocketInputStream.read(SocketInputStream.java:116)
     at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
     at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
     at java.io.FilterInputStream.read(FilterInputStream.java:66)
     at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:442)
     at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
     at java.lang.Thread.run(Thread.java:536)
trap this and deal with it appropriatly.
hope this helps.
Charbel.

Similar Messages

  • How to send message to Client about Server shutdown.

    I have made a Chatting Application using RMI.
    I need to send messages to all the Clients when a Server shutdowns abnormally.
    One way is that I use shutdown hook on the Server Application.
    But, what if the power of the machine on which server is running goes off. How will the Client get to know that server is down.
    I also want that If a Client shutdowns abnormally,it should send the message to the Server which in turn will send message to other Clients about the particular Client.
    Thanks & Regards.
    Nimesh

    Before you make any call form client to server check that sever is available. This is easily done by intorudciing an rmi method that will return true e.g m_sever.isAvalable(); if server is availbel you will get ture if not then you will get an RMI Excpetion which you then trap and attemp to reconnect to the server (NAming.lookup() ) .. if several attempts fail then assume server is down.
    When a client dies it throws an excpetion on the sErver :
    java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:116)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
         at java.io.FilterInputStream.read(FilterInputStream.java:66)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:442)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
         at java.lang.Thread.run(Thread.java:536)
    trap this and deal with it appropriatly.
    hope this helps.
    Charbel.

  • Sending message across clients

    Hello,
    wanted to know how to send message across clients. Suppose I have 2 XI servers : one is XI other is PI. I want to send message from PI to XI. how will we configure this scenario? what adapters will be used and what is the message flow ?
    Thank you.

    Hi,
    Check my thread it may be helpful
    XI adapter
    Regards,
    Prakash

  • How to send message to MDB from different clients.

    Hi,
    I want to know how to send message to a Message Driven Bean residing in EJB container from
    1. Web Component
    2. Application Client
    3. Another Entity Bean
    4. Non J2EE client.
    If you provide me any tutorial link on this it would be really helpful.
    Thanks for the time.

    Hi,
    refer to http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/MDB.html#74108
    Seetesh

  • How to send message from Message Driven Bean  to JMS client?

    In my project I have JMS client, two QueueConnectionFactory and Message Driven Bean. Client send message to MDB through the first QueueConnectionFactory , in one's turn MDB send message to client through the second Queue Connection Factory . I already config my Sun AppServer for sending message in one way, and sending message from MDB to the second QueueConnectionFactory. But on my Client there is an error : �JNDI lookup failed: javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/MyQueue2� (jms/MyQueue2 � this is the name of my Queue). So it couldn't get this message.
    P.S.
    Thank you for help!!!

    What is the name of the second queue?is the connection factory on the local?Yes the connection factory is on the local. The name of my first queue is jms/MYQueue and the name of another one is jms/MyQueue2.

  • How to  send messages via shareobject in FMS

    How to send messages via shareobject in FMS
    I need some codes.
    I want to send some string messages via shareobject, the
    string messages can be retrieve in client.
    Can you give me some codes? Thank you for your help..
    /

    Thanks for your comment.
    en....I want to do something..I will maintenance a users list
    in charroom.
    I write a function in main.asc file , client can get users
    list via call the function.
    I write some codes in application.onConnect
    when a user connect, it will add users list.
    In application.onDisconnect, when a user disconnect, it will
    remove from users list.
    My hope when a user disconnect, I send a message to
    shareobject. the shareobject is called in other clients.
    Other client can retrieve the remove user message, they will
    call the function to get new users list.
    It is my idea. Can you give me some codes for my idea?
    Thank you very much.

  • How to send messages to the specified user through sap

    how to send messages to the specified user through sap

    Hi Santosh,
    try:
        CALL FUNCTION 'TH_POPUP'
             EXPORTING
                  CLIENT         = SY-MANDT
                  USER           = BNAME "User you want
                  MESSAGE        = MSG "text you want
             EXCEPTIONS
                  USER_NOT_FOUND = 1.
    Regards, Dieter

  • In solman 4.0 how to send message to SAP through service desk

    Dear all,
            I have configured service desk functionality, My requirement is from service desk how to send message to SAP.
    Regards,
    Pavan.

    Hi,
    Following the steps:
    &#131;Basic configuration - RFC Connections to SAP
    Check if the RFC Connectino SAPOSS is working properly
    Check if load distribution group is set to EWA
    The RFC Connections:
    - SAP-OSS (Send Message to SAP)
    - SAP-OSS-LIST-O01 (Update Message from SAP)
    will be created automatically by the system with a user which has been assigned
    previously.
    IMG Path: SAP Web Application Server | SAP Web Application Server | SAP Solution Manager| Basic Settings | SAP Solution Manager System | Connection to SAP | Assign user for forwarding Service Desk Message
    With transaction SM59 you can adjust the RFC connections.
    - For further information on SAP R/3 Front-end connections, see SAP Notes: 33135, 766505, 24177
    - To forward Service Desk notifications and Issues to SAP, you need to assign a user to the SAPNet R/3
    Front-end connection to SAP.
    Activities:
    - 1. From the SAP Solution Manager (transaction SOLUTION_MANAGER), choose (Edit-> Global Settings.
    - 2. Choose Display<->Change.
    - 3. For SAP Service Marketplace, specify http://service.sap.com as the URL.
    - 4. In the Connection to SAP tab, specify SAPOSS as the RFC destination. Note that the entry is casesensitive.
    - 5. For User forwading messages, enter a valid user and a password. This user will require all the authorizations for SAPNet R/3 Front-end for your customer number.
    - 6. Save your changes.
    The system automatically generates the following RFC destinations and assigns the S-User and password you specified: SAP-OSS, SAP-OSS-LIST-O01
    Good Lucky!

  • How to send messages in iChat in plain text? (no html)

    How to send messages in iChat in plain text? I don't need any formatting nor hiding links in achor tags.

    HI,
    In the View Menu once you have a Chat window open is the Messages item which allows you to change the style of the IM.
    However this still sends a HTML like packet for dispalyiing the info at the other end.
    This does not work to ICQ users.
    Chax, an iChat Add-on, works in iChat 5 and lower (although there are then different versions) and can strip out the HTML part for sending to ICQ users.
    However there is not yet a Lion/iChat 6 version.
    8:43 PM      Monday; December 12, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • How to send message to a multi-consumer queue using pl/sql

    How to send message to a multi-consumer queue using pl/sql ? Thanks.
    I tried following, but got an message: no receipient specified.
    DBMS_AQ.ENQUEUE(
    queue_name => 'aqadm.multi_queue',
    enqueue_options => queue_options,
    message_properties => message_properties,
    payload => my_message,
    msgid => message_id);
    COMMIT;
    END;
    /

    Here's two way to enqueue/publish new message into multi-consumer queue.
    (1) Use explicitly declared recipient list
    - Specify "Recipients" by setting recipient_list to messge_properties, before ENQUEUE().
    DECLARE
    recipients DBMS_AQ.aq$_recipient_list_t;
    BEGIN
    recipients(1) := sys.aq$_agent('RECIPIENTNAME',NULL,NULL);
    message_properties.recipient_list := recipients ;
    (2)Or, declare subscriber list permanently. Then you need not to specify recipient list each time you call ENQUEUE().
    begin
    dbms_aqadm.add_subscriber(
    queue_name=>'YOURQUEUE',
    subscriber=> sys.aq$_agent('RECIPIENTNAME', null, null)
    end;
    You can add 1024 local subscriber include maximum 32 remote-queue-consumer to one queue.

  • I don't know how to send message to my friends via message

    I downloaded mountain lion yesterday but I don't know how to send message to the imessage on ipad or iphone. The account of my friend's seems doesn't work and I have no access to sending message to that account.

    Welcome to Apple Communities
    Press the + button to select a contact. Then, write whatever you want in the white box and press Enter key. You can use it with contacts with iPhone, iPod touch, iPad or Mac with Mountain Lion

  • How to send message to non android mobiles?

    I am not able send SMS to other mobile etc. SMS are being sent as iMessages only to apple products.  How to send messages to others?

    The iPad cannot send SMS texts - it is not a cellular phone, and SMS texting is a cellular phone feature (SMS uses the voice channel to send).
    You will have to get a 3rd party app to send SMS texts by internet - check the App store for what is avaialble.
    You can also send SMS texts as email if you know the persons phone number and their carrier, using their carrier's email-to-text gateway
    see http://en.wikipedia.org/wiki/List_of_SMS_gateways for a list of carriers and their gateway addresses.

  • How to send message/traffic accross VME bus from NI's VME MXI-2 card So I can monitor messages via vmetro card?

    Hi,
    How to send message/traffic accross VME bus backplane from NI's VME MXI-2 card?
    So that I can monitor messages via vmetro card/BusView?
    Thanks
    DBhagat

    Hi Dbhagat,
    The VME-MXI-2 card is a type of VME controller, which is used in conjunction with a PCI-MXI-2 card that will be in an external computer. This computer is then able to send and receive messages to other devices on the VME bus, as well as monitor the information on the bus.
    Hope this helps!
    john
    Applications Engineer

  • How to send message to another ipod user

    Hello Team ,
    Please help me to understand , how to send message to another user of Ipod
    I am having ipod 4G touch , So please guide me on this .
    also Can we pair ipod to any bluetooth head set  , Curretnly i having Samsung strero phone head phone model no SBH650 .
    Please help me ....
    Thank you
    Regards
    Mahesh

    Hi
    Please check FM <b>TH_POPUP</b>
    Is this what you require ?

  • HT4623 how to send messages in bulk

    how to send messages in bulk

    HI,
    In the View Menu once you have a Chat window open is the Messages item which allows you to change the style of the IM.
    However this still sends a HTML like packet for dispalyiing the info at the other end.
    This does not work to ICQ users.
    Chax, an iChat Add-on, works in iChat 5 and lower (although there are then different versions) and can strip out the HTML part for sending to ICQ users.
    However there is not yet a Lion/iChat 6 version.
    8:43 PM      Monday; December 12, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

Maybe you are looking for