B4J Tutorial [ABMaterial] IMPORTANT change for B4J 5.80

Discussion in 'B4J Tutorials' started by alwaysbusy, Jul 13, 2017.

  1. alwaysbusy

    alwaysbusy Expert Licensed User

    As in B4J 5.80 Jetty has been updated to 9.4.6 (which contains an important change in the internal Session framework), you will need to update some code in StartServer() and StartServerHTTP2() in the ABMApplication module.

    In pre B4J 5.80 with Jetty 9.3.x it was:
    Code:
    Dim joServer As JavaObject = srvr
    joServer.GetFieldJO(
    "server").RunMethod("stop"Null)
    joServer.GetFieldJO(
    "context").RunMethodJO("getSessionHandler"Null).RunMethodJO("getSessionManager"Null).RunMethodJO("getSessionCookieConfig"Null).RunMethod("setMaxAge"Array(31536000)) ' 1 year

    'NEW FEATURE! Each App has its own Session Cookie
    joServer.GetFieldJO("context").RunMethodJO("getSessionHandler"Null).RunMethodJO("getSessionManager"Null).RunMethodJO("getSessionCookieConfig"Null).RunMethod("setName"Array(ABMShared.AppName.ToUpperCase))
    joServer.GetFieldJO(
    "server").RunMethod("start"Null)
    must be changed to this in B4J 5.80+ with Jetty 9.4.6:
    Code:
    Dim joServer As JavaObject = srvr
    joServer.GetFieldJO(
    "server").RunMethod("stop"Null)
    joServer.GetFieldJO(
    "context").RunMethodJO("getSessionHandler"Null).RunMethodJO("getSessionCookieConfig"Null).RunMethod("setMaxAge"Array(31536000)) ' 1 year
       
    ' NEW FEATURE! Each App has its own Session Cookie
    joServer.GetFieldJO("context").RunMethodJO("getSessionHandler"Null).RunMethodJO("getSessionCookieConfig"Null).RunMethod("setName"Array(ABMShared.AppName.ToUpperCase))
    joServer.GetFieldJO(
    "server").RunMethod("start"Null)

    ' This setting is with reservation until confirmation
    Dim secs As Long = ABMShared.CacheScavengePeriodSeconds ' must be defined as a long, else you get a 'java.lang.RuntimeException: Method: setIntervalSec not matched.' error
    joServer.GetFieldJO("context").RunMethodJO("getSessionHandler"Null).RunMethodJO("getSessionIdManager"Null).RunMethodJO("getSessionHouseKeeper"Null).RunMethod("setIntervalSec"Array As Object(secs))
    @mindful and @stanmiller:
    Can you confirm this last line is ok? I think it is now needed as in 9.4.6 there is a default session scavenger running every 10 minutes. However, as we have our own scavenger running too, this interval may be to short.

    I have tested quite a bit the updated jServer lib, but if ABMaterial users find some other problems, please post them in this topic.

    Note: I'm on vacation from the 19th of juli and back at the 27th and have very limited internet capabilities in this period.

    Alwaysbusy
     
  2. mindful

    mindful Active Member Licensed User

    @alwaysbusy I don't think there is any improvement in setting the session scavenger at the same interval as the cachedpages scavenger interval - what if you have expired sessions and the cached pages scavenger runs before the session scavenger ... the cached page will remain in memory and the session will not exist (this is just a thought - not tested) ... this is a good snippet so that others can see how they can tweak/improve jetty settings!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice