Creating a server shutdown object

Why and when to perform this task

When a CORBA server is started, it initializes itself, calls the execute_request_loop()method, and specifies a blocking mode (::CORBA::BOA::SOMD_WAIT). This puts the server into an infinite wait loop during which the ORB transmits requests to and from the servant object hosted by the server. Because the execute_request_loop() method never returns, the server can never terminate unless it is forced. A server shutdown object makes it possible to terminate the server gracefully. The server creates a server shutdown object and gives it a string that is used to shut down the server.

To stop the server, run the WSStopServer program, which tells the ORB to shut the server down. WSStopServer has the following command syntax:

WSStopServer server_alias

where server_alias is the server alias (defined in the Implementation Respository).

To create a WSServerShutdown object, modify the server's main() function by adding the following code:

int main ( int argc, char *argv[] )
{
   .
   . initialization code
   .

   .
   . create and bind the servant object
   .


   // Create a WSServerShutdown object that can break the server out of the
   // execute_request_loop() method when we are ready to terminate
   // the server. The WSStopServer command will cause the subsequent
   // invocation of execute_request_loop() return to the server.
   WSServerShutdown *shutdownObj = new WSServerShutdown ( serverAlias, boaPtr );
   cout << "Created WSServerShutdown object" << endl;

   .  
   .  
   .  
}

When created, the WSServerShutdown object is initialized with the server alias and the object adapter pointer.

Results

This task adds code to create a WSServerShutdown object. After the server has initialized itself, it creates the WSServerShutdown object, which waits for a message informing it that the server is to be shut down. That message can be sent by the StopServer command line program provided with WebSphere Application Server enterprise services.

What to do next

To continue developing the server main code, add code to put the server into an infinite wait loop. During this loop, the Object Request Broker (ORB) can transmit requests to and from the servant object hosted by the server as described in Putting the server into an infinite loop.

Related tasks
Creating the CORBA server main code (server.cpp)
Putting the server into a loop to service requests



Searchable topic ID:   tcor_pgms5f
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/corba/tasks/tcor_pgms5f.html

Library | Support | Terms of Use | Feedback