publishAndWait reply and waitForreply usage

First off all I’m just beginning with webmethods IS :D(yehai) right now so sorry if there is some misspelled information…

When we want to use publishAndWait there are two alternatives sync or async. The async way provides a implementation to multi-threading.

Having an architecture as the following (for example):

-Two services: one that calls publishAndWait (first service) and another who calls the reply (second service)
-Two documents: one publish by the first service and the other that gets “replyed” by the second service

Synchronized publishAndWait

On the sync approach the flow in the first service will stop until it receives a reply from a service who subscribed the previous published document.

By other means the output will have the output variables as stated:

tag = null
document = document received from reply

Asynchronous publishAndWait

Using these paradigm we will require to use service waitForReply as well so that we only get a tag variable filled from the publishAndWait call.

tag = IS auto generated id
document = null

With this tag variable we can call waitForReply and get the desired associated reply!

So basically my doubt is:

Is there a difference between an Asynchronous publishAndWait and a normal publish if we don’t use a waitForReply?
And by that I mean an Asynchronous publishAndWait is useless without a waitForReply…

And another thing if we put the waitForReply immediately after an Asynchronous publishAndWait (in the flow) the we are actually making a sort of
Synchronized publishAndWait :rolleyes:

ps: i searched the forum but I didn’t actually saw a description of how to implement stuff like this and how it worked so after reading the manuals and implementing some examples i got to this conclusions.

tks for your time cheers :cool:

Luis,

   We have to use [B]Publish and Wait[/b] model when we are in need of some information which the publishing service needs to process from the subscriber service. 

Eg:
This model can be used when a service requests for some dB update and expects succeful response.
The values that need to be updated can be published in a document and the subscriber service will update it in dB. In the mean time, the service will be waiting for a succesful response. So if the dB insertion is successful a success message can be replied so that publishing service will proceed with next step.

    I think you are right with the second question which you asked.:)

-Ambrish-

ty I see u backup my point!

No difference. Without a waitForReply, publishAndWait is just a publish–though the responder will still respond. It’s just that the reply will be ignored.

Correct.

The usual case for doing async publishAndWait is to publish 2 or more requests and then gather the responses. In theory this can be more time efficient as multiple requests are sent in parallel instead of serially.

I’ve never seen a scenario where this approach was needed/useful.

Also, it has been my experience that publishAndWait is rarely needed.

“The usual case for doing async publishAndWait is to publish 2 or more requests and then gather the responses. In theory this can be more time efficient as multiple requests are sent in parallel instead of serially.”

Well Master Reamon that was exactly the case. :wink:

In my problem there were 12 different sources and only 3 outputs and but that output should be entered in the exact same order of entrance with the best performance possible.

I was just clarifying that I was doing the correct theoretical approach (with WM) I think u said it all! This thread can be closed!! tks allot