+

Search Tips   |   Advanced Search

Configure stateful session bean failover at the application level

Use scripting and wsadmin.sh to configure applications for stateful session bean failover.

Start wsadmin.

We can use the AdminConfig object to set configurations in an application. In this task, you use the AdminConfig object to display the stateful session bean failover configuration for all EJB modules in the application. Then, you use the AdminConfig object to modify the stateful session bean failover configuration for all the EJB modules in the same application.

  1. Start the wsadmin scripting client.

    • Using Jacl
      wsadmin 

    • Using Jython
      wsadmin -lang Jython
                              

  2. Identify the deployment configuration object for the application and assign it to the deployment variable; for example:

    • Using Jacl
      set app [$AdminConfig getid /Deployment:EJBinWARTest/]
      set depObj [$AdminConfig showAttribute $app deployedObject]
                              

    • Using Jython
      app = AdminConfig.getid("/Deployment:EJBinWARTest/" )
      depObj = AdminConfig.showAttribute(app, "deployedObject" )
                              

  3. Get the application configuration object. If it does not exist, create it.

    • Using Jacl
      # Get the single application configuration object:
      set appConfig [lindex [$AdminConfig showAttribute $depObj configs] 0]
       
      # Create the application configuration object if not present:   if { ($appConfig == "") } {
        puts "\nappConfig not present - creating one"
        set appConfig [$AdminConfig create ApplicationConfig $depObj {{enableSFSBFailover true} {overrideDefaultDRSSettings false}}]
        set attrs [list config $appConfig]
        set targetMappings [lindex [$AdminConfig showAttribute $depObj targetMappings] 0]
        $AdminConfig modify $targetMappings [list $attrs]
      } else {
        puts "\nappConfig present"
      }
                               

    • Using Jython
      appConfig = AdminConfig.showAttribute (depObj, 'configs')
      appConfig = appConfig.replace('[','').replace(']','')
       if (appConfig):
        print "\nappConfig present"
      else:
        print "\nappConfig not present - creating one"
        acAttrs = []
        attr1 = ["enableSFSBFailover", "true"]
        attr2 = ["overrideDefaultDRSSettings", "false"]
        acAttrs.append(attr1)
        acAttrs.append(attr2)
        appConfig = AdminConfig.create('ApplicationConfig', depObj, acAttrs)
        tmAttrs = ['config', appConfig]
        targetMappings = AdminConfig.showAttribute (depObj, 'targetMappings')
        targetMappings = targetMappings[1:len(targetMappings)-1]
        AdminConfig.modify(targetMappings, [tmAttrs])
                               

  4. Display the stateful session bean failover configuration settings of the application.

    • Using Jacl
      puts "\nStateful session bean failover settings at the application level"
      puts [$AdminConfig show $appConfig]
       
      # Show the drsSettings of the application:
       set drsSettings [$AdminConfig showAttribute $appConfig drsSettings]
      if { ($drsSettings == "") } {
        puts "drsSettings not present"
      } else {
        puts "\ndrsSettings of the application:"
        puts [$AdminConfig show $drsSettings]
      }
                              

    • Using Jython
      print "\nStateful session bean failover configuration of the application :"
      print AdminConfig.show(appConfig)
       drsSettings = AdminConfig.showAttribute (appConfig, 'drsSettings')
      if (drsSettings):
        print "\ndrsSettings of the application:"
        print AdminConfig.show(drsSettings)
      else:
        print "drsSettings not present"
                              

  5. Enable stateful session bean failover for the application.

    • Using Jacl
      $AdminConfig modify $appConfig {{enableSFSBFailover "true"}}
                              

    • Using Jython
      # Enable Stateful session bean failover for the application:
      AdminConfig.modify(appConfig, [['enableSFSBFailover', 'true']])
                              

  6. Add or modify the data replication service settings for the application.

    • Using Jacl
      # To add or modify drsSettings for the application:
       set drsSettings [$AdminConfig showAttribute $appConfig drsSettings]
      if { ($drsSettings == "") } {
        puts "\ndrsSettings not present - creating them"
        $AdminConfig create DRSSettings $appConfig "{messageBrokerDomainName ReplicationDomain2}"
      } else {
        set newMessageBrokerDomainName "{messageBrokerDomainName ReplicationDomain2}"
        $AdminConfig modify $drsSettings $newMessageBrokerDomainName
      }
       $AdminConfig modify $appConfig {{overrideDefaultDRSSettings "true"}}
       
      # Show the new or modified drsSettings of the application:
       set drsSettings [$AdminConfig showAttribute $appConfig drsSettings]
      puts "\nModified drsSettings of the application:"
      puts [$AdminConfig show $drsSettings]
                              

    • Using Jython
      drsSettings = AdminConfig.showAttribute (appConfig, 'drsSettings')
      if (drsSettings):
        newMessageBrokerDomainName = "{messageBrokerDomainName ReplicationDomain2}"
        AdminConfig.modify(drsSettings, newMessageBrokerDomainName)
      else:
        print "\ndrsSettings not present - creating them"
        drsAttr1 = ["messageBrokerDomainName","ReplicationDomain2"]
        drsAttrs = []
        drsAttrs.append(drsAttr1)
        AdminConfig.create("DRSSettings",appConfig,drsAttrs)
       
      AdminConfig.modify(appConfig, [['overrideDefaultDRSSettings', 'true']])
       # Show the new or modified drsSettings of the application:
       drsSettings = AdminConfig.showAttribute (appConfig, 'drsSettings')
      print "\nNew or Modified drsSettings of the application:"
      print AdminConfig.show(drsSettings)
                              


Related concepts

  • Stateful session bean failover for the EJB container


    Related tasks

  • Enable or disable stateful session bean failover with the EJB container panel
  • Enable or disable stateful session bean failover with the enterprise applications panel

  • Stateful session beans failover settings (applications)