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 <[email protected]>:
> 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 <[email protected]>
> To: Marco A Gonzalez <[email protected]>,
> [email protected]
> 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 ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]