March 24

1 comments

How to Create Different Subsystems for Web Services

By NickLitten

March 24, 2023

IBM i, ADDPJE, CRTSBSD, SQL

Do you want to Create Different Subsystems for Web Services?

There are a lot of positive reasons for us to create separate subsystems for each out our sets of applications. But if you read this blog entry then you already know that. So, assuming you want to do it — let’s stop blathering and dive right in.

First let’s look at our memory pools and decide which one we want these webservice jobs to run in.

Create different subsystems for web services

We could create a share-pool but for this example lets run them in *BASE

Create Subsystem

Let’s create a unique subsystem called MARMITE – this is where we want my webservices to run. Let’s also route any webservice connecting to our machine using USRPRF(LITTENN) and ensure they run in this subsystem.

CRTSBSD SBSD(MARMITE) POOLS((2 *BASE)) MAXJOBS(10) TEXT('Example Subsystem running in *BASE with max(10)')

Now we need to add a prestart job for the webservices to hook into.

Make a Job Queue for our new Subsystem

Let’s create a job queue and plant it in our new subsystem

CRTJOBQ JOBQ(MARMITE) Text('Job Queue for new MARMITE subsystem')

Now we attach that job queue to our subsystem

ADDJOBQE SBSD(MARMITE) JOBQ(MARMITE)

Create a Class

Now we attach that job queue to our subsystem

CRTCLS CLS(MARMITE) RUNPTY(50) TIMESLICE(5000)

Add Prestart Job Entry

Now we are going add prestart job entries

ADDPJE SBSD(MARMITE) PGM(QRWTSRVR) INLJOBS(1) THRESHOLD(1) ADLJOBS(2) MAXJOBS(50) JOBD(QDFTSVR) POOLID(2) CLS(MARMITE)
ADDPJE SBSD(MARMITE) PGM(QZDASOINIT) INLJOBS(1) THRESHOLD(1) ADLJOBS(2) MAXJOBS(50) JOBD(QDFTSVR) POOLID(2) CLS(MARMITE)

Note the class – This is where these jobs will inherit their runtime priorities.

The other parameters are self-explanatory:

  • initial jobs
  • threshold
  • additional jobs
  • maximum jobs

Now the subsystem is ready to start.

But first we need to tell IBM i to route all webservice jobs into our new subsystem — based on the user name for those webservices.

SQL SET_SERVER_SBS_ROUTING

Use SQL to make sure that all incoming connections for a specific user go to our new subsystem. IBM has given us a neat procedure that does exactly that:

The SET_SERVER_SBS_ROUTING procedure provides the ability to configure a server to use an alternate subsystem. This can be for all users of the server, for a specific user profile, or by IP address. This procedure allows an administrator to reposition certain connections to a server into an alternate, non-default, subsystem.

Use IBM i ACS Sql tool for best results:

How to create different subsystems for web services 1

Or you can use trusty old green screen STRSQL to do the same thing:

CALL QSYS2.SET_SERVER_SBS_ROUTING('username', 'QRWTSRVR', 'MARMITE')
CALL QSYS2.SET_SERVER_SBS_ROUTING('username', 'QZDASOINIT', 'MARMITE')

and that’s it!

Start that subsystem and launch some webservice connections!

STRSBS SBSD(MARMITE)

Finally – how can we see what routing is in place?

Another little SQL magic lets us see exactly what is setup:

select * from qsys2.server_sbs_routing
  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

    >