[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster] Subscriber getting first message only



Hallo David,
I tried what you described with a slightly modified HelloWorld2.java (see the code below) and could not reproduce the behaviour you described. Could you please send the client you used ?


Michele

// -------- here is the code: -----------------------


// xmlBlaster/demo/javaclients/Dummy.java import org.jutils.log.LogChannel; import org.xmlBlaster.util.Global; import org.xmlBlaster.client.qos.ConnectQos; import org.xmlBlaster.client.qos.DisconnectQos; import org.xmlBlaster.client.I_Callback; import org.xmlBlaster.client.key.UpdateKey; import org.xmlBlaster.client.qos.UpdateQos; import org.xmlBlaster.client.I_XmlBlasterAccess; import org.xmlBlaster.util.MsgUnit;


/**
* This client connects to xmlBlaster and subscribes to a message.
* <p />
* We then publish the message and receive it asynchronous in the update() method.
* <p />
* Invoke: java Dummy
* at see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/interface.html"; target="others">xmlBlaster interface</a>
*/
public class Dummy implements I_Callback
{
public Dummy(final Global glob) {
try {
I_XmlBlasterAccess con = glob.getXmlBlasterAccess();


ConnectQos qos = new ConnectQos(glob);
con.connect(qos, this); // Login to xmlBlaster, register for updates


         con.subscribe("<key oid='Dummy'/>", "<qos/>");

// A similar subscription with XPATH:
//con.subscribe("<key oid='' queryType='XPATH'>//key[ at oid='Dummy']</key>", "<qos/>");


con.publish(new MsgUnit(glob, "<key oid='Dummy'><data>one</data></key>", "Hi".getBytes(),
"<qos/>"));


try {
Thread.currentThread().sleep(200);
con.publish(new MsgUnit(glob, "<key oid='Dummy'><data>two</data></key>", "Hi2".getBytes(),
"<qos/>"));



Thread.currentThread().sleep(1000); // wait a second System.out.println("\nHit a key to logout and terminate ..."); System.in.read(); } catch(Exception e) { }

         con.erase("<key oid='Dummy'/>", null);
         con.disconnect(null);
      }
      catch (Exception e) {
         System.err.println(e.getMessage());
      }
   }

public String update(String cbSessionId, UpdateKey updateKey, byte[] content,
UpdateQos updateQos)
{
System.out.println("\nHelloWorld: Received asynchronous message '" +
updateKey.getOid() + "' state=" + updateQos.getState() + " from xmlBlaster");
return "";
}


   /**
    * Try
    * <pre>
    *   java Dummy -help
    * </pre>
    * for usage help
    */
   public static void main(String args[]) {
      Global glob = new Global();

if (glob.init(args) != 0) { // Get help with -help
System.out.println(glob.usage());
glob.getLog(null).info("Dummy", "Example: java Dummy -session.name Jack\n");
System.exit(1);
}


      new Dummy(glob);
   }
}

// ------------------- code ends here ---------------------------





David Hooker wrote:
It looks like it's my subscriber.  I have two different ones... an EXACT
subscriber, and an XPATH subscriber.

The XPATH subscriber gets all message updates.  The EXACT subscriber
only gets the first update.  The code for each is identical:

            SubscribeKey skey = new SubscribeKey(global, subscribeOID,
"EXACT");
            SubscribeQos sqos = new SubscribeQos(global);
            sqos.setWantInitialUpdate(false);
            sqos.setWantLocal(false);
            conn.subscribe(skey, sqos, this);

Except one has "EXACT" and one has "XPATH".  Why do the different
subscribers behave differently?

-----Original Message-----
From: Michele Laghi [mailto:laghi at swissinfo.org] Sent: Friday, April 04, 2003 4:15 PM
To: xmlblaster at server.xmlblaster.org
Subject: Re: [xmlblaster] Subscriber getting first message only



Hi again David,
Ok, now I see. The problem is that you published messages with the same oid and changed the key of the message. The behaviour you got is normal.


The key of a message is supposed to be immutable:

When you first publish a message, a topic is created for it with the given oid, the key of that topic is parsed and put into the BigDomTree.
Subsequent publishes on that topic (on that oid) will not parse the key anymore (the performance impact would be prohibitive) and the key is considered to be constant. Of course it is a little confusing that you did not get an exception when publishing with a new key. In fact you even will get the new PublishKey on the update method (and this extravagant side effect has been positively used by some of the xmlBlaster users).


What I still don't understand however is that you should have received an update for all three messages (provided you subscribed before the publishes).

Saluti
Michele



David Hooker wrote:

Here's the publish code:

           PublishQos pqos = new PublishQos(global);
           PublishKey key = new PublishKey(global, oid);
           String data = getFile(args[0]);
           MsgUnit msg = new MsgUnit(key, data, pqos);

           String stamp = Long.toString(System.currentTimeMillis());
           StringBuffer tags = new StringBuffer();
           tags.append("<DocSender><timestamp>");
           tags.append(stamp);
           tags.append("</timestamp>");
           tags.append("</DocSender>");
           key.setClientTags(tags.toString());

           I_XmlBlasterAccess conn = global.getXmlBlasterAccess();
           ConnectQos cqos = new ConnectQos(global);
           cqos.setSessionName(new SessionName(global, "DocSender"));
           ConnectReturnQos cretqos = conn.connect(cqos, null);

           PublishReturnQos pretqos = conn.publish(msg);

           conn.disconnect(new DisconnectQos(global));

Running the publisher program twice gives two MsgUnitWrapper's in the
TopicHandler section for the OID.  Each has a different timestamp in

the

client tags area.  However, only the first timestamp message is in the
XmlKeyDom section.

-----Original Message-----
From: Michele Laghi [mailto:laghi at swissinfo.org] Sent: Friday, April 04, 2003 3:40 PM
To: xmlblaster at server.xmlblaster.org
Subject: Re: [xmlblaster] Subscriber getting first message only



Hallo David,
in a normal case you should receive all three messages.
If you subscribe after having published the messages, then you would only get the last published message. On the other hand you say you receive only the first: if you set explicitly forceUpdate to 'false'

in


the publishQos and the content of the messages is the same, then you will only get the first one.

If none of the mentionned is your case you should send us the code.

Michele


David Hooker wrote:


I know this is probably answered somewhere, but I've looked for a

couple


of hours and can't find where.

I have a publisher which publishes a message with a fixed oid.  I have
an EXACT subscriber which subscribes to this oid.

The first message published is sent to the subscriber.  The second and
subsequent messages published are _not_ being sent to the subscriber.
The TopicHandler section for the oid has both messages stored in it,

but


only the first one is referenced in the XmlKeyDom section - the second
message isn't listed there.  Why is this?  How can I make sure all
messages after the first one are published?

(Forgive my questions... I'm new to xmlBlaster.)









--
Michele Laghi
mailto:laghi at swissinfo.org
tel. +46 8 7492952 / mob. +46 70 4103964
http://www.geocities.com/laghi2000
http://www.xmlBlaster.org