21
Thu, Nov
1 New Articles

TechTip: Explore and Leverage EJB3 on System i Now! Part II

Java
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

In the first part of this TechTip, I showed you how to install and set up the open-source application server JBoss on System i. I also covered the steps necessary to deploy the sample EJB3Trail application. This time, I will walk you through the process of integrating the JBoss instance with i5/OS work management to provide better performance and manageability of the EJB3 applications.

The i5/OS work management is far superior to that of any other operating system with which I'm familiar in terms of its ability to assign various workloads into separate subsystems with dedicated system resources. A subsystem is a predefined operating environment entity that the system uses to coordinate the work flow and resource use. In addition, a memory pool can be used to further separate the workloads. A memory pool is a division of main storage, and it can be assigned to a subsystem so that the jobs running in a given subsystem do not have to compete for memory access with jobs in other subsystems.

Now, I will use these fundamental concepts to create a shared memory pool and a separate subsystem for the JBoss application server.

Setting Up a Shared Memory Pool

The i5/OS supports both shared and private memory pools. The shared pools are more flexible, because they allow sharing of unused memory between pools and they can also use the Expert Cache. The Expert Cache is a disk cache tuner that can reduce the time to process disk I/O. The i5/OS contains 64 predefined shared pools that can be allocated to subsystems. You can use either the graphical iSeries Navigator or the CL commands to configure a shared pool. To save space (and time?), I use CL commands in the course of this TechTip.

You can use the Work with Shared Pools (WRKSHRPOOL) command to configure the shared pool for JBoss. The command displays the names and status of the shared pools. The first four pools on the list are predefined by IBM, so you need to choose one of the other pools labeled *SHRPOOL1 through *SHRPOOL60. Locate the specific pool you want to configure, say *SHRPOOL2. You need to set three parameters:

  • Defined Size (M)—This is the amount of main storage, in megabytes, defined, for the pool. The memory requirement depends on the application. A good starting point would be 1.5–2 GB of memory for a good-sized application server. Then, monitor the paging rates to see if the memory size is adequate for your environment.
  • Maximum Active—This identifies the maximum number of threads that can use the processor concurrently. Set this parameter to 500.
  • Paging Option—The paging option determines whether the system should dynamically adjust the paging characteristics of the pool for optimum performance. Set it to *CALC to enable Expert Cache tuning.


Alternatively, you could execute the following Change Shared Pools (CHGSHRPOOL) command:

CHGSHRPOOL POOL(*SHRPOOL2) SIZE(2048) ACTLVL(500) PAGING(*CALC)

Setting Up the JBoss Subsystem

The process of creating a subsystem is pretty straightforward. First, I use the Create Subsystem Description (CRTSBSD) command:

CRTSBSD SBSD(JBOSS4/JBOSS4) POOLS((1 *SHRPOOL2)) TEXT('JBoss 

processing subsystem')

For simplicity, I keep all JBoss work management objects in a separate

 library called JBOSS4. I also instruct the system to use the memory 

from the *SHRPOOL2 storage pool to service the jobs running in this subsystem.  

I create a unique job queue that is used to queue up jobs waiting to be 

processed in the new subsystem. Here's the Create Job Queue (CRTJOBQ) 

command that accomplishes this task:

CRTJOBQ JOBQ(JBOSS4/JBOSS4JOBQ) TEXT('Job queue for the JBOSS4 processing subsystem')  

The Add Job Queue Entry (ADDJOBQE) command associates the newly created job queue with the subsystem:

ADDJOBQE SBSD(JBOSS4/JBOSS4) JOBQ(JBOSS4/JBOSS4JOBQ) MAXACT(1)

The MAXACT parameter specifies that only one job from the job queue can be active at any time. This ensures that only one JBoss instance can be started from this job queue.

I use the Create Class (CRTCLS) command to create a class object that specifies the processing attributes for the jobs that use that class:

CRTCLS CLS(JBOSS4/JBOSS4) RUNPTY(20) TEXT('JBoss 4 class')

The Run Priority parameter is set to 20, which is as high as the priority of interactive jobs.

I then use the Add Routing Entry (ADDRTGE) command to create a routing entry for the subsystem. A subsystem can have more than one routing entry; however, each job uses a single routing entry. Subsystems select which routing entry to use based on the comparison value in the routing entry and the routing data string in the job. Routing entries assign a pool and a class to a job while it is being started. In this case, I want the subsystem to invoke the command processor (QCMD) to run any submitted command. Here's the command to add the necessary routing entry:

ADDRTGE SBSD(JBOSS4/JBOSS4) SEQNBR(9999) CMPVAL(*ANY) PGM(QSYS/QCMD) 

CLS(JBOSS4/JBOSS4)

The Sequence Number (SEQNBR) parameter is set to 9999, which is the maximum, catch-all value. Routing entries are searched in ascending sequence number order. So sequence 9999 is processed only if there is no match for any lower sequence number. The Comparison Data (CMPVAL) parameter specifies the string that is used to compare with the routing data to determine which routing entry is applied. The *ANY value means that any routing data is considered a match.

To have the JBoss application server start automatically after the subsystem is started, I attach an autostart job entry to the subsystem. First, however, I need to create a job description for the autostart job. An autostart job description contains all the runtime environment parameters needed to run the job. I use the Create Job Description (CRTJOBD) command to accomplish this task:

CRTJOBD JOBD(JBOSS4/JBOSS4JOBD) USER(JAREK) RQSDTA('SBMJOB CMD(QSH 

CMD(''/home/jarek/jboss4/runServer.sh'')) JOBQ(JBOSS4/JBOSS4JOBQ) 

ALWMLTTHD(*YES)')

The User parameter specifies the name of the user profile associated with
this job description. The Request Data (RQSDTA) parameter is the actual command string that i5/OS should execute. In this case, the Submit Job (SBMJOB) command is used to invoke the QShell processor. A QShell script name is passed as an input parameter to the QShell processor. (The content of this script is explained in the next section.) The Job Queue (JOBQ) parameter is used to point to a job queue associated with the subsystem, in which the job is to be executed. Finally, the Allow Multiple Threads (ALWMLTTHD) parameter set to *YES specifies that the job can run with multiple user threads. This is required, because JBoss is a multithreaded Java application.

The runServer.sh QShell script is used to set up the run-time environment for JBoss and to invoke the script to start the application server. The source of the script is listed below:

print Running $PWD/runServer.sh
CLASSPATH=$CLASSPATH:.:/opt/jboss-4.0.5.GA/bin [1]
export CLASSPATH
JAVA_HOME=/QOpenSys/QIBM/ProdData/JavaVM/jdk50/32bit [2]
export JAVA_HOME
print CLASSPATH=$CLASSPATH
print JAVA_HOME=$JAVA_HOME
cd /opt/jboss-4.0.5.GA/bin
./run.sh & [3]

At [1] in the code above, the path to the JBoss executable code is appended to the CLASSPATH environment variable. At [2], the JAVA_HOME variable is set so that the 32-bit IBM J9 JVM is enabled (see part 1 of this tip for more details). At [3], the run.sh script is invoked to start the application server.

Once the necessary job description is defined, I can use the Add Autostart Job Entry (ADDAJE) command to attach an autostart job entry to the JBoss subsystem:

ADDAJE SBSD(JBOSS4/JBOSS4) JOB(JBOSS405GA) JOBD(JBOSS4/JBOSS4JOBD)

The entry identifies the job name and the job description to be used to automatically start a job that initializes the application server.

Now I can start the JBoss subsystem with the following command:

STRSBS SBSD(JBOSS4/JBOSS4)

To verify that the subsystem started successfully, I use the Work with Active Jobs (WRKACTJOB) command:

WRKACTJOB SBS(JBOSS4) 

The dialog that appears is shown in Figure 1.

http://www.mcpressonline.com/articles/images/2002/Explore%20and%20Leverage%20EJB3%20on%20System%20i%20now!%20%20Part%20IIV4--07130700.png

Figure 1: The WRKACTJOB dialog will show whether the subsystem started successfully. (Click image to enlarge.)

The presence of the batch immediate job named QP0ZSPWP with the function set to JVM-org.jboss indicates that the JBoss application server is running.

To stop the server, I can use the following command:

ENDSBS SBS(JBOSS4) OPTION(*IMMED)

Additional Material

The process of installing the JBoss application server and the sample EJB3 application is covered in the first part of this tip: "TechTip: Explore and Leverage EJB3 on System i Now!"

Jarek Miszczyk is the Senior Software Engineer, ISV Solutions Enablement, IBM Rochester. He can be reached by email at This email address is being protected from spambots. You need JavaScript enabled to view it..

Jarek Miszczyk

Jarek Miszczyk is a Lead Technical Consultant for System x Virtualization and Cloud Computing at the IBM STG Global ISV Enablement organization. He is located in Rochester, Minnesota. He can be reached by email at This email address is being protected from spambots. You need JavaScript enabled to view it..

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: