tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johnny Kewl" <j...@kewlstuff.co.za>
Subject Re: Interapp Communications
Date Mon, 15 Sep 2008 10:15:26 GMT

----- Original Message ----- 
From: "Darryl Pentz" <djpentz@yahoo.com>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Monday, September 15, 2008 10:37 AM
Subject: Interapp Communications


> Some time back I needed to communicate between two apps running in the 
> same Tomcat instance. I decided on using a simple HTTP call with Apache 
> Commons HttpClient. For some reason use of this class is causing PermGen 
> errors (I should add that I use a dynamic language in the mix, which might 
> impact that in some way) so I want to abandon that approach anyway, 
> because it just doesn't 'feel right' :-).
>
> So I was wondering, is JMS the way to go with something like this? I see 
> Tomcat is able to use JMS via a JNDI read-only lookup.
>
> Many thanks,
> Darryl Pentz

Well, the way you doing it is also good for cross machine, cross domain.... 
you using simple SOAP... Axis "your way"...
That HTTPd client is quite heavy, maybe Java's URL Connection will do what 
you need

I dont bother too much with the stuff out there... JMS is a way, but you 
looking for JNDI registries now.
Not sure if TC built in JNDI... targeting tomcat... will be enuf?
Some very rough code for you to play with... Java really makes http very 
very easy


private byte[] loadURLFileBytes(String urlPlusFile) {

        byte[] data = new byte[0];
    try {
        URL url = new URL(urlPlusFile);

        URLConnection connection = url.openConnection();

        connection.setDoInput(true);    //GET
        connection.setUseCaches(false); // get fresh from server
        InputStream in = connection.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(in);

        int length = connection.getContentLength();

            int len;
            byte[] buffer = new byte[512];
            while ((len = bis.read(buffer)) != -1) {
                data = appendBlock(data,buffer,len);

            }

        in.close();
        bis.close();

    } catch(Exception ex) {
        //JOptionPane.showMessageDialog(null, ex.getMessage() , "Error 
during data download", JOptionPane.WARNING_MESSAGE);
        return null;
    }

    return data;
}

That all your HTTP is doing for you...
Then Tomcat can do cross contexts as well... theres a cross context flag to 
set and some code that looks like this..
The post also describes the issue...
http://forums.java.net/jive/thread.jspa?messageID=215873

One day when your site is huge, you making millions... maybe your cross 
machine way will sound good again ;)

Theres SOA/EJB as well... ;)

Have fun...
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message