REQUIREMENT interface.update |
Type | NEW |
Priority | HIGH |
Status | CLOSED |
Topic | Clients receive asynchronous messages with the update() method | ||||||||||||||||||||||||||||||||||||
Des cription |
If clients want to receive callbacks from xmlBlaster they need to install
a callback server.
The messages arrive in the update() method. Callback server method detail (CORBA IDL notation): typedef string XmlType; typedef sequence<XmlType> XmlTypeArr; typedef sequence<MessageUnit> MessageUnitArr; XmlTypeArr update(in string cbSessionId, in MessageUnitArr msgUnitArr) raises(XmlBlasterException); oneway void updateOneway(in string cbSessionId, in MessageUnitArr msgUnitArr); string ping(in string qos); As you can see the client has to provide three methods (see xmlBlaster.idl)
As default messages are sent acknowledged, if a client chooses to receive
oneway messages it has to be configured with the connect QoS
during We discuss here update() only as updateOneway() is just a subtype without return value.
Behavior on exceptions thrown by a client in update() If the If your client throws a If your client throws a
Please note that in the Java client library all other exception types thrown in your
If the server gets a communication exception
Behavior on blocking/timeout during a update() call:
When the A typical fail safe subscriber needs to set at least: java javaclients.HelloWorldSubscribe -session.name SUBSCRIBER/1 -dispatch/callback/retries -1 Summary
Please see requirement admin.errorcodes.listing for a list of error codes. The server side error handler is hidden by an interface and will be
a plugin in a future version of xmlBlaster to support customized error behavior. NoteBe prepared to receive all sorts of messages on update, like normal messages or internal xmlBlaster messages or administrative command messages. Note for XML-RPC Clients
The update interface differs a little bit with the actual XMLRPC implementation. string update( string cbSessionId, string key, byte[] content, string qos )
The XmlRpcCallbackImpl.java:update() does not allow to send an array of messages.
So for each message, XmlBlaster server will call the client's callback update method. |
||||||||||||||||||||||||||||||||||||
Example XML |
Here is an example of an update message:
And a return value from the client (sent back to xmlBlaster):
|
||||||||||||||||||||||||||||||||||||
Example XML |
Here is an example of an UpdateQos XML markup which you may receive in the <qos> <!-- UpdateQos --> <state id='OK'/> <!-- OK,ERASED etc. see Constants.java --> <sender>/node/heron/client/Tim/-2</sender> <priority>5</priority> <subscribe id='__subId:heron-2'/> <!-- Showing which subscription forced the update --> <!-- PtP messages are marked with '__subId:PtP' --> <!-- UTC time when message was created in xmlBlaster server with a publish() call, in nanoseconds since 1970 --> <rcvTimestamp nanos='1007764305862000002'> 2001-12-07 23:31:45.862000002 <!-- The nanos from above but human readable --> </rcvTimestamp> <!-- remainingLife is calculated relative to when xmlBlaster has sent the message --> <expiration lifeTime='129595811' remainingLife='1200'/> <queue index='0' size='1'/> <!-- If queued messages are flushed on login --> <redeliver>4</redeliver> <!-- Only sent if message sending had previous errors --> <!-- Only sent if message is from history queue directly after subscribe --> <clientProperty name='__isInitialUpdate'>true</clientProperty> <clientProperty name='myTransactionId'>0x23345</clientProperty> <clientProperty name='myDescription' encoding="base64" charset="windows-1252"> QUUgaXMgJ8QnDQpPRSBpcyAn1icNCnNzIGlzICffJw== </clientProperty> <clientProperty name='myAge' type='int'>12</clientProperty> <route> <!-- Routing information in cluster environment --> <node id='avalon' stratum='1' timestamp='1068026303739000001' dirtyRead='false'/> <node id='heron' stratum='0' timestamp='1068026303773000001' dirtyRead='false'/> </route> </qos> |
||||||||||||||||||||||||||||||||||||
Example Java |
A typical Java client code to handle message updates: import org.xmlBlaster.client.key.UpdateKey; import org.xmlBlaster.client.qos.UpdateQos; ... public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) { if (updateKey.isInternal()) { // key oids starting with "__" like "__cmd:..." System.out.println("Received internal message '" + updateKey.getOid() + " from xmlBlaster"); return "<qos/>"; } if (updateQos.isOk()) { // <qos><state id='OK' ... System.out.println("Received asynchronous message '" + updateKey.getOid() + "' state=" + updateQos.getState() + " content=" + new String(content) + " from xmlBlaster"); } else if (updateQos.isErased()) { // <qos><state id='ERASED' ... System.out.println("Topic '" + updateKey.getOid() + " is erased"); // Remove my subscriptionId if i have cached it ... return "<qos/>"; } else { System.out.println("Ignoring asynchronous message '" + updateKey.getOid() + "' state=" + updateQos.getState() + " is not handled"); } return "<qos/>"; } See xmlBlaster/demo/HelloWorld*.java for more examples. |
||||||||||||||||||||||||||||||||||||
Example Java |
We provide two demo clients which allow playing with the update behavior on command line. Here is an example how to simulate a subscriber which throws an exception: java -jar lib/xmlBlaster.jar java javaclients.HelloWorldSubscribe -updateException.errorCode user.update.error -updateException.message "I don't want this" java javaclients.HelloWorldPublish -numPublish 100 We start a server and a subscriber which is configured to throw an exception if a message arrives, then we start a publisher and publish messages. If we want to look a the generated dead messages we start another subscriber: java javaclients.HelloWorldSubscribe -oid __sys__deadMessage |
||||||||||||||||||||||||||||||||||||
Configure |
NOTE: Configuration parameters are specified on command line (-someValue 17) or in the
xmlBlaster.properties file (someValue=17). See requirement "util.property" for details. |
||||||||||||||||||||||||||||||||||||
See API | org.xmlBlaster.util.def.PriorityEnum | ||||||||||||||||||||||||||||||||||||
See API | org.xmlBlaster.client.key.UpdateKey | ||||||||||||||||||||||||||||||||||||
See API | org.xmlBlaster.client.qos.UpdateQos | ||||||||||||||||||||||||||||||||||||
See API | org.xmlBlaster.client.I_XmlBlasterAccess | ||||||||||||||||||||||||||||||||||||
See API | org.xmlBlaster.client.protocol.corba.CorbaCallbackServer | ||||||||||||||||||||||||||||||||||||
See API | org.xmlBlaster.client.protocol.rmi.RmiCallbackServer | ||||||||||||||||||||||||||||||||||||
See API | org.xmlBlaster.client.protocol.xmlrpc.XmlRpcCallbackServer | ||||||||||||||||||||||||||||||||||||
See API | org.xmlBlaster.util.def.Constants | ||||||||||||||||||||||||||||||||||||
See REQ | interface | ||||||||||||||||||||||||||||||||||||
See REQ | engine.qos.update.queue | ||||||||||||||||||||||||||||||||||||
See REQ | engine.qos.update.rcvTimestamp | ||||||||||||||||||||||||||||||||||||
See REQ | engine.qos.update.sender | ||||||||||||||||||||||||||||||||||||
See REQ | engine.qos.update.subscriptionId | ||||||||||||||||||||||||||||||||||||
See REQ | admin.errorHandling | ||||||||||||||||||||||||||||||||||||
See | http://www.xmlBlaster.org/xmlBlaster/src/java/org/xmlBlaster/protocol/corba/xmlBlaster.idl | ||||||||||||||||||||||||||||||||||||
See TEST | org.xmlBlaster.test.qos.TestSub | ||||||||||||||||||||||||||||||||||||
See TEST | org.xmlBlaster.test.qos.TestErase |
This page is generated from the requirement XML file xmlBlaster/doc/requirements/interface.update.xml