Graceful shutdown of a webMethods Integration Server through custom developed java program

Out of the box a webMethods Integration Server is shutdown via the Administrator screen.

Following code snippet with allow you to gracefully shutdown a webMethods Integration Server through the usage of a custom developed java program.

Java code snippet :

import java.io.*;
import com.wm.app.b2b.client.*;
import com.wm.util.*;
import com.wm.data.*;

public class IntegrationServerShutdown
{
            public String hostName = null;
            public String port = null;
            public String userName = null;
            public String password = null;
            Context context = null;
            public boolean connected = false;
            public static void main(String[] args)
            {           String input = null;
                        //Create an instance of a b2bServer
                        IntegrationServerShutdown b2bServer = new IntegrationServerShutdown();

                        b2bServer.hostName=args[0];
                        b2bServer.port=args[1];
                        b2bServer.userName=args[2];
                        b2bServer.password=args[3];
                        System.out.println(“”);
                        b2bServer.connect();
                        if(!b2bServer.connected)
                                    System.exit(0);
                        b2bServer.shutdown();

            }
            public void connect()
            {           context = new Context();
                        try
                        {           context.connect(hostName + “:” + port, userName, password);
                                    System.out.println(“Connected to ” + hostName + “:” + port);
                                    connected = true;
                        }
                        catch(ServiceException e)
                        {           System.out.println(“Could not connect to ” + hostName + “:” + port);
                                    System.out.println(e.toString());
                                    connected = false;
                        }
            }
            public void disconnect()
            {           if(context != null)
                                    context.disconnect();
            }
            public void shutdown()
            {           try
                        {
                                    System.out.println(“Shutting down IS Server… “);
                                    IData inputs = IDataFactory.create();
                                    IDataCursor myCursor = inputs.getCursor();
                                    myCursor.insertAfter(“bounce”, “no”);
                                    myCursor.insertAfter(“timeout”, “0”);
                                    myCursor.insertAfter(“option”, “force”);
                                    context.invoke(“wm.server.admin”,”shutdown”,inputs);
                                    System.out.println(“IS Server shutdown complete.”);
                                    System.exit(0);
                        }
                        catch(ServiceException e)
                        {           System.out.println(“IS Server shutdown failed.”);
                                    System.out.println(e.toString());
                                    System.exit(1);
                        }
            }

}

Remarks:

  1. When compiling and running the java program make sure to include files wm-isclient.jar and mail.jar in your class path. File wm-isclient.jar can found in the “common/lib” folder of an Integration Server whereas file mail.jar is localized in the “ext” sub folder of the “common/lib” folder.
  2. Usage of the IntegrationServerShutdown program is IntegrationServerShutdown <IS hostname> <IS port> <IS account with administrative privileges> <IS account password>
  3. At this moment the java program is working with at least webMethods Integration Server v7.1.2 and v8.2. Specifications contained herein are potentially subject to change so use them at your own risk.

Author: Johan De Wulf

blogger

blogger

Curious to know more about this topic?

Working at i8c

i8c is a system integrator that strives for an informal atmosphere between its employees, who have an average age of approx 30 years old. We invest a lot of effort in the professional development of each individual, through a direct connection between the consultants and the management (no multiple layers of middle management). We are based in Kontich, near Antwerp, but our customers are mainly located in the triangle Ghent-Antwerp-Brussels and belong to the top 500 companies in Belgium (Securex, Electrabel, UCB, etc…).

Quality Assurance

i8c is committed to delivering quality services and providing customer satisfaction. That’s why we invested in the introduction of a Quality Management System, which resulted in our ISO9001:2000 certification. This guarantees that we will meet your expectations, as a reliable, efficient and mature partner for your SOA & integration projects.

i8c - ISO9001-2015

Also worth reading

AWS AppFlow: Streamlining SaaS Integrations with AWS Services

In today’s digital world, organizations are constantly looking for ways to streamline their workflows and improve their data management processes. One of the key challenges that organizations face is integrating their various software as a service (SaaS) applications with their data management systems. This is

Read More »

Apigee Scope Validation using OpenAPI Specification

In API security and management, we often use a lot of different security mechanisms to protect the requested resource behind the API Gateway. One of these mechanisms is the validation of scopes to authorize a client on a specific sub-resource of the API. Most of

Read More »