Recovery from GMD_FAILURE messages is highly specific to the application, and SmartSockets cannot perform it on its own. The GMD_FAILURE message notifies the process that there is a problem, and the process can take whatever user-defined action is needed. SmartSockets by default outputs a warning, terminates GMD for the failed message, and continues.
When GMD fails, a GMD_FAILURE message is created internally by SmartSockets. TipcSrv.process is called to process the message and notify the sender that there has been a GMD failure. GMD programs can create connection process callbacks for the GMD_FAILURE message type to execute their own recovery procedures. The failed message is left in the connection GMD area, and it is up to the GMD_FAILURE process callbacks to delete the message, terminating GMD for that message, or resend the message.
Each GMD_FAILURE message contains four fields:
The only type of GMD_FAILURE message produced for non-RTclient or non-RTserver GMD is a delivery timeout failure. The third field of the GMD_FAILURE message is TipcSrv.ERROR_GMD_SENDER_TIMEOUT.
Connections automatically check for delivery timeouts whenever data is read from the connection (with TipcSrv.next) or the connection is checked to see if data can be read (with TipcSrv.check). You must use TipcSrv.next and TipcSrv.check frequently enough.
The default GMD failure callback is a sample callback designed only to warn the user that guaranteed delivery of a message has failed. You should create applications that destroy the callback and create their own process callbacks for GMD_FAILURE messages, performing actions such as a recovery procedures you design.
To obtain the default callback for GMD_FAILURE, use the TipcSrv.getDefaultGmdFailureCb method. To register a new GMD_FAILURE callback, use the TipcSrv.addProcessCb with a message type of TipcMt.GMD_FAILURE.
Here is an example of a process callback:
import java.io.*; import com.smartsockets.*; public class gmd_example { private static final int SAMPLE = 1001;/*=============================================================== */
/*..gmdFailureMsgCallback - callback for gmd failure */
public class gmdFailureMsgCallback implements TipcProcessCb { public void process(TipcMsg msg, Object arg) { System.out.println("GMD failure"); TipcMsg sender_msg = null;//* get published message header and contents */
try { sender_msg = msg.nextMsg(); } catch (TipcException e) { Tut.fatal(e); }// catch
// point to error id field
try { msg.setCurrent(2); } catch (TipcException e) { Tut.fatal(e); }// catch
int error_number = 0; try { error_number=msg.nextInt4(); } catch (TipcException e) { Tut.fatal(e); }// catch
// print out message saying what happened
switch (error_number) { case 518: System.out.println("GMD sender timed out"); break; case 519: System.out.println("GMD receiver timed out"); break; case 520: System.out.println("GMD receiver exited"); break; case 521: System.out.println("No receivers for subject: " + sender_msg.getDest() + ""); break; default: System.out.println("Unknown error code: " + error_number); break; }// remove copies of message
try { TipcSrv srv=TipcSvc.getSrv(); srv.gmdMsgServerDelete(sender_msg);// delete from server
srv.gmdMsgDelete(sender_msg);// delete from local spool
} catch (TipcException e) { Tut.fatal(e); }// catch
System.out.println("FAILED MESSAGE Follows"); sender_msg.print(); }// process callback
}// gmdFailureMsgCallback
TIBCO SmartSockets™ Java Library User’s Guide and Tutorial Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |