WebSphere Application Server - Accessing MBeans to know how many active seesions are on

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Application Server > April 2006 > Accessing MBeans to know how many active seesions are on





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Accessing MBeans to know how many active seesions are on

2006-04-11, 10:17 am

Dear all,

I have started using Websphere, one week back. We have a login servlet, acting as the entry point to a complex enterprise application. I would like to instantiate the connection to MBean in the init of the servlet and initialize a count variable, which is
static. Now inside the doPost of the servlet, I will increment the count variable, as when a new login occurs. I will also be checking whether the count has reached a maximum threshold, say 50. If the user is the 51st one, I will redirect to a message, s
aying "Wait for sometime, as the number of connections had reached its limit".

Can the experts out there, show me a link or snippet code by which I can connect to the MBean which manages the number of connections of may ear file ? Assume the name of the ear file is "somename.ear".

Thanks a lot for the time, patience and help.

Warmest regards,
Ravishankar
Paul Ilechko

2006-04-11, 10:17 am

rshankarn@acm.org wrote:
> Dear all,
>
> I have started using Websphere, one week back. We have a login
> servlet, acting as the entry point to a complex enterprise
> application. I would like to instantiate the connection to MBean in
> the init of the servlet and initialize a count variable, which is
> static. Now inside the doPost of the servlet, I will increment the
> count variable, as when a new login occurs. I will also be checking
> whether the count has reached a maximum threshold, say 50. If the
> user is the 51st one, I will redirect to a message, saying "Wait for
> sometime, as the number of connections had reached its limit".


What exactly do you expect to achieve by doing this? Other than annoying
your users for no apparent reason, that is. When do you think you will
be able to decrement your counter, given that users rarely bother to
actually log off from applications, they just close the browser or
navigate somewhere else, and you have no way of trapping these actions.

2006-04-11, 10:17 am

Dear Paul,

I understand your reasons. But that is why I am relying on the MBean which controls the number of active sessions. Hence if the user is going to someother webpage or closing the browser, then MBean should know that the session is being invalidated, thats
not my headache anyway.

I worked with a tool called spotlight for WebLogic, which shows the number of active connections, at any point of time, accurately, irrespective of whether user closed the browser abruptly or navigated to another page, of course depedning on some tomeout
mechanism.

Hence I would like to see that. And another thing - it is not for annoying users dear friend, its because we have taken money from customers only for 50 concurrent logins.This way we are kepping a limit as specified in the SLA.

Now lets us proceed, can you please give some snippet of code to access the MBean responsible for the web container and show me how to access the number of sessions, thanks

Best regards,
Ravishankar
Paul Ilechko

2006-04-11, 10:17 am

rshankarn@acm.org wrote:

> I understand your reasons. But that is why I am relying on the MBean
> which controls the number of active sessions. Hence if the user is
> going to someother webpage or closing the browser, then MBean should
> know that the session is being invalidated, thats not my headache
> anyway.


The session won't be invalidated until the it times out. So you may
actually have no-one working on the system, and no available
connections. This is not optimal.


> Hence I would like to see that. And another thing - it is not for
> annoying users dear friend, its because we have taken money from
> customers only for 50 concurrent logins.This way we are kepping a
> limit as specified in the SLA.


Then you have a problem with your pricing model. If you want to only
allow a certain number of concurrent users, which is not the same thing
as concurrent logins, you can manage that better by playing with
thread-pool sizes, and you won't have to write any code.
Ben_

2006-04-11, 10:17 am

> allow a certain number of concurrent users, which is not the same thing
> as concurrent logins

What difference do you make between "concurrent users" and "concurrent
logins" ?
I understand the OP wants that no more than 50 persons use the application
at the same time, whatever the number of "registered users" / "named users"
/ "licensed user" is.

> you can manage that better by playing with
> thread-pool sizes, and you won't have to write any code.

It seems more difficult to me.
You have to foresee capacity for intensive use of the application by the
maximum number of users.
If I understand you correctly, you'd create a bottleneck on the Web
Container. But this will only slow down access, not prevent access.
Or do you have something different in mind ?

Alternate solution I'm thinking to: use an HttpSessionListener to invalidate
the newly created session immediatly if the number of active sessions
exceeds the maximum allowed ?


Ken Hygh

2006-04-11, 10:17 am

rshankarn@acm.org wrote:
> Dear all,
>
> I have started using Websphere, one week back. We have a login servlet, acting as the entry point to a complex enterprise application. I would like to instantiate the connection to MBean in the init of the servlet and initialize a count variable, which

is static. Now inside the doPost of the servlet, I will increment the count variable, as when a new login occurs. I will also be checking whether the count has reached a maximum threshold, say 50. If the user is the 51st one, I will redirect to a message,
saying "Wait for sometime, as the number of connections had reached its limit".
>
> Can the experts out there, show me a link or snippet code by which I can connect to the MBean which manages the number of connections of may ear file ? Assume the name of the ear file is "somename.ear".
>
> Thanks a lot for the time, patience and help.
>
> Warmest regards,
> Ravishankar


There is no MBean that maintains how many current sessions are
'connected' to your ear file.

Just use a singleton and implement the ceiling yourself.

Ken
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com