Patrick,
Thank you for your interest in my situation.
This issue has raised concerns for me that Inline:Java is not safe in
a web environment (multiple users at once), but I know others are
using it, so I am hoping that it is merely my implementation.
On Jun 10, 2005, at 9:08 AM, Patrick LeBoutillier wrote:
Luke,
On 6/9/05, Luke Chambers <[EMAIL PROTECTED]> wrote:
I am trying to use Inline Java under mod_perl.
The code that I am running forks right before it executes the Inline
Java sub. It is a very expensive sub... a web services call.. so I
want it to run asynchronously.
How exactly does this work? The user sgets a HTTP response before
the web services call is over? How do provide him with the answer?
Because if you fork and wait for the child to finish, you don't
need to fork...
The user does not need to know what the result of the web services
call is (essentially, I am duplicating data over to another system).
So what I need to do is do an update locally, spawn the process to do
the remote update and return to the user (as the spawned process is
doing it's thing).
I am having a hard time getting it to run properly. It seems to
execute the first request and ignore all others until the first has
completed.
If you do that you must have the new child re-connect to the JVM
server
or else it will share the same connection as the parent and mess
things up.
Check the docs for Inline::Java::reconnect_JVM.
Can you send some code so that I can understand the login better?
I thought you only needed to call Inline::Java::reconnect_JVM if the
fork() occurred in the block where your Inline Java code existed.
Since I am forking before the Java code, do I not need it?
Here's some code:
---------
sub spawn_webservices_process{
my ($clientParameters, $synchronize) = @_;
my $pid;
if(!$synchronize){
defined($pid = fork) or die "Can't fork: $!";
}
if ($pid) {
#parent returns immediately
return;
} else {
#do the child stuff
setsid or die "Can't start a new session: $!";
print STDERR "BEGINNING ASYCHRONOUS WEBSERVICES CONTACT
(pd: $$)\n";
&do_web_services_update($clientParameters);
print STDERR "COMPLETED ASYCHRONOUS WEBSERVICES CONTACT\n";
exit(0);
}
}
-------------
sub gradebook_update_student_value{
my ($do_web_services_update) = @_;
BEGIN {
$ENV{CLASSPATH} .= ":/usr/local/tii/global/lib/
webct_webservices/jars/VistaSDKClient-2_0_0.jar";
.........
$ENV{CLASSPATH} .= ":/usr/local/tii/global/lib/
webct_webservices/jars/turnitinWebServicesClients.jar";
}
use Inline (
Java => 'STUDY',
SHARED_JVM => 1,
STUDY => [
'com.iparadigms.webct.webServiceClient.GradeBook',
'java.util.HashMap'],
DIRECTORY => '/tmp/',
) ;
use Inline::Java qw(caught);
my $new_column_id;
eval {
#..... MY JAVA CODE FOR THE WEB SERVICES UPDATE
} ;
if ($@){
if (caught("java.lang.Exception")){
my $msg = [EMAIL PROTECTED]>getMessage() ;
undef($@);
$logger->error("Inline Java Exception: ".$msg);
die("Inline Java Exception: ".$msg);
} else {
$logger->error("Wect Web Services Error: ".$@);
die("eb Services Error: ".$@);
}
}
}
----------
Are there any special precautions that I need to take when doing this
sort of thing with Inline Java?
Besides what is stated above I don't think so.
Thanks
Luke
Thanks again!
--
=====================
Patrick LeBoutillier
Laval, Québec, Canada