Borland(R) Enterprise Server VisiBroker(R) デベロッパーズガイド
オペレーション要求の送信には,応答を待ち続けないメソッドであるsend_deferredも使用できます。このメソッドを使用したクライアントは,リクエストを送信したあと,poll_responseメソッドを使用して応答が返ってきているかどうかを調べることができます。get_responseメソッドは,応答を受信するまで待ちます。コードサンプル17-20にsend_deferredメソッドとpoll_responseメソッドを使用して遅延DIIリクエストを送信する方法(C++),コードサンプル17-21に遅延DIIリクエストを送信する方法(Java)を示します。
. . . try { // Create request that will be sent to the manager object CORBA::Request_var request = manager->_request("open"); // Create argument to request CORBA::Any customer; customer <<= (const char *) name; CORBA::NVList_ptr arguments = request->arguments(); arguments->add_value( "name" , customer, CORBA::ARG_IN ); // Set result type request->set_return_type(CORBA::_tc_Object); // Creation of a new account can take some time // Execute the deferred request to the manager object request->send_deferred(); VISPortable::vsleep(1); while (!request->poll_response()) { cout << " Waiting for response..." << endl; VISPortable::vsleep(1); // Wait one second between polls } request->get_response(); // Get the return value CORBA::Object_var account; CORBA::Any& open_result = request->return_value(); open_result >>= CORBA::Any::to_object(account.out()); . . . }
try { . . . // Create request that will be sent to the manager object org.omg.CORBA.Request request = manager._request("open"); // Create argument to request org.omg.CORBA.Any customer = orb.create_any(); customer.insert_string(name); org.omg.CORBA.NVList arguments = request.arguments(); arguments.add_value("name", customer, org.omg.CORBA.ARG_IN.value); // Set result type request.set_return_type(orb.get_primitive_tc (org.omg.CORBA.TCKind.tk_objref)); // Creation of a new account can take some time // Execute the deferred request to the manager // object-plist request.send_deferred(); Thread.currentThread().sleep(1000); while (!request.poll_response()) { System.out.println(" Waiting for response..."); Thread.currentThread().sleep(1000); // Wait one second between polls } request.get_response(); // Get the return value org.omg.CORBA.Object account; org.omg.CORBA.Any open_result = request.return_value(); account = open_result.extract_Object(); . . . }catch(Exception e) { e.printStackTrace(); }
All Rights Reserved. Copyright (C) 2008, Hitachi, Ltd.
COPYRIGHT (C) 1992-2004 Borland Software Corporation. All rights reserved.