[erlang-questions] Strategies to connect from Java

Alexander Lamb alexander.lamb@REDACTED
Wed Apr 23 14:59:38 CEST 2008


Hello List,

Now that I have my first 3 Erlang modules (I think I may have reached  
the "aha point") and looking forward to the conference in London in  
June where I hope I will gain some OTP knowledge, I would like to  
connect to those modules from Java.

Yes, since we live in an non perfect world, we are using Java with  
Tapestry as our Web environnement (a very powerfull library, but that  
is another matter).
Each user, when login in, will create a session and start working.

I am therefore writing some Java classes to call my Erlang functions.  
The Java api is the one supplied with R12 version of Erlang.

Now, I imagine there are 3 possibilities:

A)
Each time I call a function, create a new OtpConnection to the Erlang  
node, once done, close the connection.

B)
The first time I call a function, create a new OtpConnection to the  
Erlang node, leave it open until the app is stoped. The scope of the  
connection would be for the entire application deployed in a container  
(e.g. Tomcat). In a situation with more than one app server (for a  
cluster for example), there would be one OtpConnection per server.

C)
The first time I call a function from a session, create a new  
OtpConnection. Close the connection when the user logs out or the  
session times out.


Solution A is obviously the most "no side effects compatible" but  
might be really slow. In addition, I need to be carefull when trying  
to create two connections at the same time from two separate Java  
threads... so either I create a connection per thread or I lock  
(defeats the purpose of Erlang).

Solution B is maybe slightly better since I could create the  
connection when starting the Java server. I still have the locking  
issues, though.

Solution C seems good and scales in terms of parallelism, but it leads  
to 2 questions:

1)
How many connections can I make from Java before running out of file  
descriptors or whatever is needed to handle connections? In our  
current business, I don't see more than 200 concurent users before  
many months...

2)
If I only need to initiate function calls (e.g. the Erlang modules  
don't need to call me), I don't need to create (I assume) a node for  
the Java client. However, if at some point, I need to be called from  
Erlang, I will need to generate a new node name (and a new OtpSelf)  
for each new session. Is this correct?

Thanks for any hints...

Alex
--
Alexander Lamb
Founding Associate
RODANOTECH Sàrl

4 ch. de la Tour de Champel
1206 Geneva
Switzerland

Tel:  022 347 77 37
Fax: 022 347 77 38

http://www.rodanotech.ch






More information about the erlang-questions mailing list