Connecting External Job Management Systems To The Sap Netweaver Scheduler For Java
Connecting External Job Management Systems To The Sap Netweaver Scheduler For Java
Interface
SAP JAVA-JXBP 7.1 Version 1.1 Java External Interface for Background Processing
Copyright
Copyright 2009 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, OpenPower and PowerPC are trademarks or registered trademarks of IBM Corporation. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
Contents
1. 2. 3. INTRODUCTION OVERVIEW THE FUNCTION OF EXTERNAL INTERFACES 5 5 6
6
6 7 7 8 8 9 9 9
4.2 Architecture and Concepts of the SAP NetWeaver Scheduler for Java 4.2.1 Architecture 4.2.2 Jobs and Job Definition 4.2.3 Job Statuses 4.2.4 Parent/Child Functionality 4.2.5 Events 4.2.6 Logging and Tracing
5.
5.1 5.2
10
10 11
6.
CERTIFICATION REQUIREMENTS
11
Symbols
Symbol Meaning Warning Example Tip Recommendation Syntax
1. Introduction
This document describes the connection of an external job management system (often called an external scheduler) to the SAP NetWeaver Application Server Java (AS Java). For this purpose, SAP has defined a public interface called JXBP, which stands for Java eXternal interface for job Background Processing. JXBP is one of a range of open interfaces, which SAP makes available for system management tasks.
2. Overview
Chapter 3 4 Contents General description of the external interfaces function. Short introduction to SAP NetWeaver AS Java background processing. In this chapter you can find details for the Java Scheduler concept, architecture, and terminology. Description of the requirements for using the JXBP interface. This chapter contains information of how to configure external schedulers in the SAP NetWeaver Administrator and the necessary security settings. Certification requirements. This chapter describes, what you need, in order to certify your usage of the JXBP interface. JXBP interface description
SAP System
Open Interfaces
Fig. 3.1: Location of external interfaces The external interfaces provide simple and seamless integration of the SAP system into both local administrative tools and business-wide system management infrastructures. The benefit from the integration is to provide the customer with a homogenous information infrastructure. The role of the interface is to facilitate the flow of information between the SAP system and the external tools.
For simplicity, in this documentation we refer to the SAP NetWeaver Scheduler Java as the Java Scheduler. The scope and the features of the Java Scheduler are similar to those offered by the CCMS ABAP Scheduler (transactions SM36 and SM37) in AS ABAP. The Motivation section below explains why background processing in general has a place in a dialog-oriented standard application, while the Architecture section explains the concept and the terminology concerning the Java Scheduler.
4.1 Motivation
SAP NetWeaver is a platform used for interactive applications. In other words, the vast majority of tasks are carried out in dialog with the user. However, there are also good reasons for the inclusion of a background processing system in AS Java. Besides the tasks carried out in a dialog, there are tasks processing large amounts of data and requiring lots of resources that do not need user interaction. With the help of the background processing system, such tasks are normally scheduled for times when the load on the system is low (during the nights, weekends, and so on), in order to avoid resource conflicts with the dialog users. At the scheduled point in time, these tasks are started by the background processing system and executed without user interaction. This mechanism is especially useful for tasks that have to be carried out periodically,
6
for example each week or each month. In the background processing system, these tasks including the period - have to be specified once only. No further action is required from the user with respect to the regular execution.
4.2 Architecture and Concepts of the SAP NetWeaver Scheduler for Java
4.2.1 Architecture
The figure below outlines the architecture of the Java Scheduler:
Jobs are implemented on the basis of message-driven beans. A message-driven bean containing a job is called a JobBean. The execution of JobBeans is handled by the EJB container. A JobBean is executed when it receives a Java Messaging Service (JMS) message from the scheduler runtime service. In cluster environment, the JMS is responsible for load balancing: it decides which JobBean instance on which node gets the request to run. For a description of the job and job definition concept see section 4.2.2. The Java Scheduler defines two services: Scheduler Runtime Service Controls all runtime aspects of a job. It handles the execution of jobs on the server node where it is running, provides error handling, and maintains job definitions and job runtime information, such as job parameters and log files. Scheduler Service Schedules jobs deployed on the application server and submits them to the scheduler runtime service. The scheduler service accepts requests for rescheduling, canceling and deleting jobs. The two services store the complete state of the Java Scheduler in the database. In cluster environment, the scheduler runtime service is deployed and runs on every cluster node. The scheduler service is also deployed on all cluster nodes, but it runs
7
only on a single node at a time. The node where it runs is designated as the singleton node. If the singleton node goes down, the scheduler service gets activated on another cluster node. This mechanism ensures the scheduler service failover.
The Java Scheduler supports child jobs (see section 4.2.4) and job chains. As a runtime object, a job has a life cycle characterized by job statuses (see section 4.2.3 below). Jobs also write logs (see section 4.2.5).
Status Starting
Description The job is currently being started. The status starting is possible when a JMS message was sent to trigger the job but the job has not yet received it. This delay in the JMS message receipt is possible if currently there are not enough threads to run a job.
The job is currently performing its unit of work. The job has finished its unit of work. The job has completed its unit of work but threw an exception during execution or indicated failure by invoking an API method. The state of the job is not known. The status unknown is possible when a node, during its start up, detects that there are jobs currently running on it.
Unknown
Canceled
The execution of the job was canceled while the job was in status starting.
If you try to cancel a job in status running, it gets canceled cooperatively. The job acknowledges the request for cancellation but may or may not get canceled. If the job gets canceled, it changes its status from running to either completed, or error. The job does
8
not change to status canceled. If the job does not get canceled, it remains in status running.
The figure below shows the possible job statuses and their transitions.
Error
Starting
Running
Completed
Canceled
Unknown
4.2.5 Events
The Java scheduler has an event concept. When starting a job, the external scheduler marks a job as running. When, for example, the job has been finished, the external scheduler needs to be informed for the status change. This information exchange takes place via events. An event is generated, whenever the job changes its status. Unhandled events are the new events. Events that have been already read are called 'handled' event. See also the method overview in section 6.2.
The log for a job is deleted when the corresponding job is deleted, for example when the jobs retention period has expired. Job logs are not overwritten by a Rotating log file set strategy. You can retrieve a log written by a particular job no matter on which server process the job ran, or whether the node where the job ran is still part of the cluster. The Java Scheduler allows managing the size of job records in the database. A job has a retention period denoting the number of days that a job record is persisted in the database. To prevent database overflow caused by too many job logs, in the job definitions deployment descriptors jobs retention period can be configured. Scheduler level (Java Scheduler logs) By default, the Java Scheduler logs are logged under the /System/Server category, at SYS_SERVER.
Scheduler. With the user name the scheduler authenticates itself, so that SAP NetWeaver knows which external scheduler connects. Inactivity Grace period As soon as an external scheduler is registered, it occupies resources on the server. And if this external scheduler does not connect to the Java system for a longer period, it would unnecessarily occupy resources that could be used otherwise. To prevent this, you can enter here an interval. If the external scheduler does not connect again within this interval, the resources are released for other purposes
It is recommended to configure this interval to be non-infinite in order to avoid keeping redundant resources. 4. Choose Add.
6. Certification Requirements
If you would like to certify your usage of the JXBP external interface, there are some requirements to be fulfilled: You should have at least one valid SAP NetWeaver Developer User license. You can obtain a license at http://www.sap.com/community/survey/index.epx?SurveyID=1089 You need SAP NetWeaver 7.1 Application Server Java installation. The supported version is 7.1 Enhancement Package 1 SP 4 or higher. The test catalogue, which is part of the same certification package (JAVAJXBP71TC.pdf), should be executed successfully.
The latest state of the requirements can be found in SAP Note 1396620.
11
The non-SAP system A creates data using a background job. The SAP system B then processes this data in a job. This means that there is a job Y in SAP system B, which can only start after job X in non-SAP system A has finished. Such a scenario demonstrates the need for a central job management system. The SAP background processing system cannot monitor jobs of non-SAP systems. In addition, the interdependencies between jobs even in a single system are sometimes so complex that they cannot be described with the functions of the internal batch API. A central job management system (often referred to as external scheduler) connects to the SAP ABAP system via the XBP interface and to the SAP Java system via the JXBP interface. In order to manage jobs centrally in a system landscape containing non-SAP systems, the non-SAP systems also have to provide an interface to which the external scheduler can connect.
12
Description Returns all job definitions known to the AS Java. It might throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem. Return the JobDefintion object for a given job definition name, where: jobName - the name of searched job If there is no such job definition, return null. It might throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
Gets a JobDefinition object by its job definition ID, where: id an identifier of searched job definition If there is no such job definition, return null. It can throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
Job Methods
Method JobID executeJob(JobDefinitionID jobDefId, JobParameterWS[] jobParametersWS, Integer retentionPeriod) throws ParameterValidationException, NoSuchJobDefinitionException, JXBPException Description Submits the job for immediate execution, where: jobDefId an identifier of the job definition, which instance will be triggered for execution jobParametersWS an array of JobParameterWS consisting of all parameters required for execution. retentionPeriod overriding the default period, after which the job artifacts (job itself, job logs, job parameters, etc) can be automatically removed(by CleanJob) from scheduler database. Returns JobID of the submitted job. Can throw an exception when the provided parameters are not valid, or there is no job definition with provided jobDefId or when the user is not authenticated or authorized or when there is resource (like database) problem. JobID executeJob(JobDefinitionID jobDefId, JobParameterWS[] jobParametersWS, Integer retentionPeriod, String vendorData) throws ParameterValidationException, NoSuchJobDefinitionException, JXBPException Submits the job for immediate execution, where: jobDefId an identifier of the job definition, which instance will be triggered for execution jobParametersWS an array of JobParameterWS consisting of all parameters required for execution. The parameters can be obtained from the corresponding job definition. retentionPeriod overriding the default period, after which the job artifacts (job itself, job logs, job parameters, etc) can be automatically removed(by CleanJob ) from scheduler database. vendorData data string to associate with the executing job. The maximum length allowed for 13
Method
Description vendor data is 200 characters. Returns JobID of the submitted job. Can throw an exception when the provided parameters are not valid, or there is no job definition with provided jobDefId or when the user is not authenticated or authorized or when there is resource (like database) problem or when vendor data sting is too long.
Cancels a job, where: jobid an identifier of the job, which will be canceled. If the job has not been started it will immediately go into CANCELLED state. If it has been started, it will cooperatively try to abort the job. This method will just return with no indication whether the job was successfully cancelled or not. Can throw JobIllegalStateException if the job is not in status RUNNING, NoSuchJobException if there is no such job or JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
Removes all information about this job instance from the SAP NetWeaver AS Java (including logs), where: jobid an identifier of the job to remove Can throw JobIllegalStateException if the job is not in status COMPLETED or ERROR or UNKNOWN or CANCELLED. Can throw also NoSuchJobException if a job with the given job id does not exist. Can throw and JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
Removes all records of the given job instances from the SAP NetWeaver AS Java (including logs), where: jobids identifiers of the jobs to use Can throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem. This is a convenient method. Logical errors (e.g. one or more jobs in an illegal state) will be ignored.
Returns the job for the given job ID, where: jobid the job identifier to use If there is no job with that jobid, return null. Can throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
Returns all parameters for the given job, where: jobid the job identifier to use Can throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem or when there is no job with 14
Description given jobid. Return all jobs for the given job IDs, where: jobids the jobs identifiers to use Returns array with size equal to the count of found jobs, or null if no any jobs has found. Can throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
This method will return all the jobs which match the provided filter criteria. If the result set is bigger than the provided fetchSize parameter, the remaining entries can be retrieved using the returned iterator. The following code snipped shows how to retrieve the result from the call: JobIteratorWS iter = jxbp.getJobs(myFilter, null, 1000); List<JobWS> jobs = iter.getJobs(); //do something with the returned //job objects //if you want to get more jobs iter = iter.getJobs(myFilter, iter, 1000); List<JobWS> jobs = iter.getJobs(); Parameters: jobFilterWS the pre-initialize filter object (may be used to filter by status, start/end time, job id etc..) iterWS custom job iterator, which can be returned from the previous call. For first call it can be null. fetchSize indicate the maximum count of the records to be fetched. Return JobIteratorWS, which contains the result. Can throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
Returns the status of a job, where: jobid the job identifier to use The method can throw NoSuchJobException if there is no job for given id. Can throw and JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
Returns all jobs with particular status, where: s the status of searched job (e.g. STARTING, COMPLETED, ERROR etc.) iterWS custom iterator, which can be returned from the previous call. For first call it can be null. fetchSize indicate the maximum count of the records to be fetched.
15
Method
Description Return JobIteratorWS, which contains the result. Can throw and JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
Method
Description jobid an identifier of job for which the log is retrieved. it custom job log iterator, which can be returned from the previous call. For first call it can be null. fetchSize indicate the maximum count of the records to be fetched. Return LogIteratorWS, which contains the result. Can throw NoSuchJobException if a job with the given job id does not exist. Can throw and JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem .
Removes the job log for the given job, where: jobid an identifier of job for which the log will be removed Can throw NoSuchJobException if a job with the given job id does not exist. Can throw also JobIllegalStateException if the job is not in status COMPLETED or ERROR or UNKNOWN or CANCELLED. Can throw and JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem .
17
Event Methods
Method EventWS[] getUnhandledEvents(int fetchSize) throws JXBPException Description Returns all unhandled events, where: fetchSize indicate the maximum count of the records to be fetched. Returns all events for the current logged-in subscriber (external scheduler). The events which have been queued for this subscriber are marked as consumed and will not be returned anymore. Can throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem or when fetchSize is not a positive number. void clearEvents() throws JXBPException Clears all events which have been returned by thw method getUnhandledEvents. 18
Can throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem. String[] getJXBPRuntimeEventTypes() void setFilter (String[] eventType) throws JXBPException Returns string array of runtime event type names, which are used by the scheduler runtime. Allows a scheduler to specify which events it is interested in. If setFilter has not been called for a particular external scheduler, that scheduler will not be subscribed for any events. Parameters: eventType an array of event type names (e.g. com.sap.scheduler.runtime.JobStarting, com.sap.scheduler.runtime. JobFinished)
Can throw JXBPException when the user is not authenticated or authorized or when there is resource (like database) problem.
19