Kelli, On Mon, 2 Dec 2002, Kelli Fuller wrote:
> >I've read >http://www.xmlblaster.org/xmlBlaster/doc/requirements/engine.qos.subscribe.initialUpdate.html > but I guess I'm still not understanding how this works. You're saying that >if I set InitialUpdate(false) then the initial update will run for messages >published AFTER I subscribe? Does this have to occur in the same process? >When I set InitialUpdate(false), then subscribe, I never get the messages >so I'm not sure what I'm doing wrong. Let me provide some code as an example: (old Style) (this may not be comlete) [a new style example can be published as well, if you subscribe to one] public class SubscribeExampleOldStyle implements I_Callback { public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) { String contentS = new String(content); if ( log.isDebugEnabled() ) { log.debug("Received asynchronous message '" + updateKey.getOid() + "' state= '" + updateQos.getState() + "' content= '" + contentS + "' from xmlBlaster."); } // -- if debug return "</qos>"; } // -- update private void subscribe(String myOidString) { SubscribeKeyWrapper ski = new SubscribeKeyWrapper( myOidString ); SubscribeQosWrapper sqi = new SubscribeQosWrapper(); sqi.setInitialUpdate(false); try { // subscribe with our own update handler SubscribeRetQos sri = iCon.subscribe(ski.toXml(), sqi.toXml(), this); log.debug("successfully subscribed for '" + myOidString + "'"); } catch (Exception e) { log.error( e.toString(), e ); return; } // -- try catch } // -- subscribe } // -- class So, if you call subscribe, then the update-method will be invoked, as soon as some _new_ message with the oid specified in myOidString can be published by xmlBlaster. If you set 'setInitialUpdate' to true, you will get an update if there has been a message published with the given oid earlier than the subscribe call. > >I have 2 Java applications, one that publishes the messages and one that >subscribes to them. I run the publish and that puts 10 messages on the >queue. Then I run the subscribe and I get nothing so I don't understand. Is >there something else I need to be setting? Yes, considering the chronological cycle as described above. The publisher in app1 and the subscriber in app2 can be different processes written in different languages residing on different computers. Let's see it as a news paper abonnement. The paper will be published every day, but as long as you don't subscribe, you won't get any. As soon as you subscribe, a newly publishd copy will be in your post box every morning. (Hopefully ;-) If you set setInitialUpdate to true, they will send you the paper of the actual day as well. If set to false, you have to wait until the next new paper will be delivered. Next point would be to have some update queue specified. You are subscribed, but your client connection is interrupted, because someone disconnected the modem or so. So all messages you subscribed to will be stored in the queue waiting to your subscriber being back online. Now you will get all messages in the right order as synchron calls of the update-method. This however is only working if you subscribe before the messages will be published. Otherwise xmlBlaster wouldn't know that it should keep some copy for you. Read http://www.xmlblaster.org/xmlBlaster/doc/requirements/engine.queue.html for more details. > >Thanks for the information on the new version. We are planning on switching >to the new version but we can't until after the 4th because we are trying >to put a demo together which involves using xmlBlaster and since I am still >trying to learn what I have now, there isn't time to make that switch. Good Luck for the demo! cheers Heinrich > > > Thanks so much for your help, > Kelli > > > Kelli, > > > I actually thought about splitting the processing up. My concern was that > > after the messages in the queue were subscribed to once, I didn't want them > > to be subscribed to again. I thought that if I set the initial update to > > FALSE, that I would only be able to subscribe to new messages on the queue > > once and only once. But instead what I found was that I couldn't subscribe > > to anything ever with this setting. The following code is what I used to > > implement this: > > > > String sSubscribeKey = "/xmlBlaster/key/TRANSACTION[@type='billing' or > > @type='estimate']"; > > SubscribeKeyWrapper sk = new SubscribeKeyWrapper(sSubscribeKey, > > Constants.XPATH); > > SubscribeQosWrapper sq = new SubscribeQosWrapper(); > > sq.setInitialUpdate(false); > > SubscribeRetQos subRet = con.subscribe(sk.toXml(), sq.toXml()); > > > > Am I misunderstanding what setInitialUpdate() does? > > Is it possible that the messages that are being published to the xmlBlaster > > queue are not being published as 'new' messages for some reason? > InitialUpdate(false) forces not to send updates for the last messages in > the queue which have been published before you placed your subscribe. > > See: > >http://www.xmlblaster.org/xmlBlaster/doc/requirements/engine.qos.subscribe.initialUpdate.html > > Remark beside: I see at your code that you not using the latest release of > xmlBlaster. It is strongly recommended to switch to the latest release > since the old one will not be supported any more in respect of new > features. > > Expect some small amount of time porting your code to the new package > structure. > > Just switch -deprecation on and see what the compiler tells you what to do > ;-) > > Happy hacking! > > regards > > Heinrich