Hi Calvin,

My app was already fetching the application().activeSessionsCount() from
the server every 30 seconds.
So now in the same DirectAction I also update a new small table in my
database with a row for each of my instances and two columns(Instance ID,
active count). I can now fetch this data and display the active counts of
the other instances of my app. I had to add a little extra so that when an
instance's last session terminated the count in the database would go down
to zero, to do this I overrid the terminate() function in Session.java to
something like this:

public void terminate(){
// If this is the last session on the instance we update the DB session
count to 0 before terminating it
if(this.application().activeSessionsCount() == 1){
EOEditingContext editingContext = this.defaultEditingContext();
String instanceId =
String.valueOf(this.context().request().applicationNumber());
WebInstance instance = WebInstance.fetchRequiredWebInstance(editingContext,
ERXQ.equals(WebInstance.ID_KEY, Integer.valueOf(instanceId)));
instance.setActiveCount(0);
editingContext.saveChanges();
}
}
super.terminate();
}

2016-09-12 18:33 GMT+02:00 Calven Eggert <cal...@mac.com>:

> Thomas,
>
> I'm interested in knowing the solution you used. thanks.
>
> Calven
> -----------
> Message: 3
> Date: Mon, 12 Sep 2016 18:01:53 +0200
> From: Thomas LATTER <latter...@gmail.com>
> To: Marco A Gonzalez <marco...@mac.com>,
> webobjects-dev@lists.apple.com
> Subject: Re: get active session count for all instances
> Message-ID:
> <CABavYTD86kZn8DT1eb6wj8Ln41h7F=t40dkyt5z7q24gzgm...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Thanks Marco,
>
> I found a solution to this. Yes I have got all this in my JavaMonitor, but
> I needed to retrieve the info in java to display on screen from within one
> of the instances. So now I just continuously update a small table in a
> database with the active counts of each instance.
>
> Thomas
>
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to