Redwood Documentation

Product Documentation

 

›RedwoodScript

RunMyJobsRedwoodScript Development

Developing Applications

  • Developing Applications

RedwoodScript

  • RedwoodScript
  • Scripting in the Shell
  • Mixing REL and RS Code in a Library
  • Controlling Process Servers with RedwoodScript
  • Controlling Queues with RedwoodScript
  • Managing Applications with RedwoodScript
  • Substitution Parameters
  • Date Formatting and Parsing
  • Impact of Modified Process Definitions or Chain Definitions on Processes and Chains
  • Using the RedwoodScript Definition Type
  • Using RedwoodScript in Processes
  • Using Eclipse to Create and Edit Process Definitions

Debugging Your Code

  • Changing Process Logging Levels

Triggering Custom Code

  • Triggering Custom Code
  • Using Triggers
  • Trigger and Action Examples
  • Using Actions
  • Executing Your Own Classes from a Library
  • Library Examples
  • Extending Redwood Server Functionality with Extension Points
  • Extending Edit Pages with ObjectPageExtensionPoint
  • Creating Extension Points
  • Extending Redwood Server Functionality with Extension Points

Using Tables

  • Using Tables to Store Frequently Used Values

PL/SQL API

  • Cronacle PL/SQL API Module
  • Creating the OracleJob Process Server
  • Using the OracleJob Definition Type
  • Packages
  • RS/JCS Views

Tuning Redwood Platform

  • Tuning Redwood Platform

Memory Tuning

  • Tuning Memory Usage and Garbage Collection

Reference

  • Using SQL to Query the Data Model
  • Embed Redwood Server Overviews into Extension Points with the Embed API
  • API Documentation
  • Script Date Formats
  • Datamodel
  • Redwood Expression Language Functions and Implicit Objects
  • RedwoodScript Scripting Contexts and Implicit Objects
← Mixing REL and RS Code in a LibraryControlling Queues with RedwoodScript →

Controlling Process Servers with RedwoodScript

When you have a lot of repetitive tasks to perform, it is often easier to use script. RedwoodScript allows you to control process servers, and you can edit all process servers, regardless of the total number, with a few lines of code. The following examples illustrate how you can use RedwoodScript to control process servers. Redwood does not warrant that this is the most effective way to solve your problem. For more information on RedwoodScript, see the API documentation.

Example

Starting and Stopping Process Servers

{
  // get the process server in the Global partition (needless to specify partition)
  ProcessServer pServer = jcsSession.getProcessServerByName("TR2_ProcessServer");

  //stop the test process server
  pServer.stop();
  jcsSession.persist();

  //start the production process server
  pServer.start();
  jcsSession.persist();
}


Adding a Process Server to a Queue

The following example can be used to add a process server into a queue and display all queues the process server is currently serving.

{
  // get the queue and the process server in partition Part
  Partition partition = jcsSession.getPartitionByName("RW_DEMO");
  Queue queue = jcsSession.getQueueByName(partition, "TR50_Queue");
  ProcessServer pServer = jcsSession.getProcessServerByName(partition, "TR5_ProcessServer");

  //create a queue provider
  pServer.createQueueProvider(queue);

  //save data in the database
  jcsSession.persist();

  //go through all queue providers of the process server
  for (QueueProvider provider : pServer.getQueueProviders())
  {
    //print the queues
    jcsOut.println(provider.getQueue().getName());
  }
}


Adding a Definition Type

When you add a definition type to a process server in the user interface, the process server automatically gets the respective service. This is not the case in RedwoodScript, the service has to be added as well. The process server needs to be shutdown for the code to work.

{
  //get the process server, the definition type as well as the service
  Partition partition = jcsSession.getPartitionByName("RW_DEMO");
  ProcessServer pServer = jcsSession.getProcessServerByName(partition, "TR5_ProcessServer");
  JobDefinitionType jdType = jcsSession.getJobDefinitionTypeByName("KSH");
  Service psService = jcsSession.getServiceByName("PlatformAgentService");

  //add definition type and service to process server
  pServer.createProcessServerJobDefinitionType(jdType);
  pServer.createProcessServerService(psService);

  //add the mandatory process server parameters required by the ''PlatformAgentService'' service.

  ProcessServerParameter RemoteHostName = pServer.createProcessServerParameter();
  RemoteHostName.setName("RemoteHostName");
  RemoteHostName.setValue("192.168.1.3");

  ProcessServerParameter SharedSecret = pServer.createProcessServerParameter();
  SharedSecret.setName("SharedSecret");
  SharedSecret.setValue("SomeBase64");
  jcsSession.persist();
}


Shutdown All Process Servers

Retrieve the process servers using executeObjectQuery.

{
  String query = "select ProcessServer.* from ProcessServer where Name <> 'System'";
  for (ProcessServer pServer : jcsSession.executeObjectQuery(ProcessServer.TYPE, query))
  {
    jcsOut.println("Stopping process server " + pServer.getName() + ", which has the status " + pServer.getStatus() + ".");
    pServer.stop();
    jcsSession.persist();
  }
}


Delete Processes that ran on a Process Server

You want to delete all the processes of a process server because you want to delete the process server, you may proceed as follows:

The following example illustrates how to delete all the processes that ran on process server MSLN_WINS3.

{
  String query = "select Job.* from Job where ProcessServer = ?";
  for (Job process : jcsSession.executeObjectQuery(Job.TYPE, query, new Object[] {jcsSession.getProcessServerByName("MSLN_WINS3").getUniqueId()}))
  {
    if(process != null)
    {
      jcsOut.println("Deleting process " + process.getDescription() +
      ", which has the status " + process.getStatus() + ".");
      process.deleteObject();
    }
    jcsSession.persist();
  }
}


Adding a database Object Reference to a JDBC Process Server

When you create a JDBC process server, you must link the process server to a database object which contains the connection settings for the JDBC connection.

The following code adds a database reference for database Example.MSLN_DB2 to Example.MSLN_JDBC1.

{
  Partition p = jcsSession.getPartitionByName("Example");
  Database db = jcsSession.getDatabaseByName(p, "MSLN_DB2");
  ProcessServer ps = jcsSession.getProcessServerByName(p, "MSLN_JDBC1");
  ObjectReference objRef = ps.createObjectReference(db);
  objRef.setName(Database.OBJECT_REFERENCE_NAME_JDBC_PROCESSSERVER);
  jcsSession.persist();
}



See Also

  • Process Server Parameters
  • Process Server Services
  • Files
  • Creating Platform Process Servers
  • Privileges Required to use Process Servers
  • Creating AS/400 Process Servers
  • Creating a Process Server
  • Configuring a Process Server
  • Process Server Parameters

Redwood Script

← Mixing REL and RS Code in a LibraryControlling Queues with RedwoodScript →
  • Example
  • Starting and Stopping Process Servers
  • Adding a Process Server to a Queue
  • Adding a Definition Type
  • Shutdown All Process Servers
  • Delete Processes that ran on a Process Server
  • Adding a database Object Reference to a JDBC Process Server
  • See Also
Docs
Getting StartedInstallationFinance InstallationConcepts
TroubleshootingArchiving
Learn and Connect
Support Portal
BlogEventsResources
ISO/ IEC 27001 Information Security Management
Automate to be human

2023 All Rights Reserved |

Terms of Service | Policies | Cookies | Glossary | Third-party Software | Contact | Copyright | Impressum |