Tom,

Sorry for not giving the details. Let me correct my mistake.

I have a situation where I need to push data from server side java 
application to the flex client. Some processes running on the server 
will generate alerts which need to be passed to the Flex client. I 
use FDS and JMS successfully for some areas of the project where the 
traffic is high and server constantly pushes data. 

Since the alerts will be sporadic, creating a JMS topic seem an 
overkill. So I decided to take advantage of Tomcat 6's Comet data 
streaming feature. I wrote a prototype pushlet on the server side 
which pushes string messages to the client as soon as the connection 
with the client is established.

Here's how the pushlet looks

public class PushServlet extends HttpServlet implements 
CometProcessor {

public class MessageSender implements Runnable {

            protected boolean running = true;
            
            
            public MessageSender() {
            }
            
            public void stop() {
                running = false;
            }
        
            
        
            public void run() {
        
                while (running) {
        
                    synchronized (connections) {
                        
                        // Send any pending message on all the open 
connections
                        for (int i = 0; i < connections.size(); i++) {
                            try {
                                PrintWriter writer = connections.get
(i).getWriter();
                                for (int j = 0; j < 10; j++) {
                                        writer.println("Push 
message "+j);
                                    writer.println("<br>");
                                }
                                writer.flush();
                            } catch (IOException e) {
                                System.out.println("IOExeption 
sending message"+e.getMessage() );
                            }
                        }
                    }
                }
            }
        }
}

This part runs fine when I hit the url 
http://localhost/myproject/pushlet 

On the flex side, I wrote the following http service to establish 
connection to the pushlet

<mx:HTTPService id="push" url="http://localhost/myproject/pushlet"; 
result="showResult();" />

I put push.send() in creationComplete of the application and 
showResult() just has an Alert.show("Hi"); to indicate that 
HTTPService did return something.

But this is not working. Let me know if there's a way to make this 
work. 

Regards,
Amit



--- In [email protected], Tom Chiverton <[EMAIL PROTECTED]> 
wrote:
>
> On Tuesday 06 Nov 2007, Amit Gupta wrote:
> > I tried using HTTPService with POST method, but it didn't work.
> > Please help.
> 
> Friendly hint: unless you say why, and what you've tried, no one 
will help 
> (how can we ?).
> 
> -- 
> Tom Chiverton
> Helping to apprehensively utilize user-centric metrics
> on: http://thefalken.livejournal.com
> 
> ****************************************************
> 
> This email is sent for and on behalf of Halliwells LLP.
> 
> Halliwells LLP is a limited liability partnership registered in 
England and Wales under registered number OC307980 whose registered 
office address is at St James's Court Brown Street Manchester M2 
2JF.  A list of members is available for inspection at the registered 
office.  Any reference to a partner in relation to Halliwells LLP 
means a member of Halliwells LLP.  Regulated by The Solicitors 
Regulation Authority.
> 
> CONFIDENTIALITY
> 
> This email is intended only for the use of the addressee named 
above and may be confidential or legally privileged.  If you are not 
the addressee you must not read it and must not use any information 
contained in nor copy it nor inform any person other than Halliwells 
LLP or the addressee of its existence or contents.  If you have 
received this email in error please delete it and notify Halliwells 
LLP IT Department on 0870 365 8008.
> 
> For more information about Halliwells LLP visit www.halliwells.com.
>


Reply via email to