Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Hi Paho team.

Hi Jianing,
the use of waitForCompletion() and and the deliveryComplete() callback are not normally used together:
  • waitForCompletion() turns an an asynchronous operation like publish (on the MqttAsyncClient) into a blocking operation.  Once the waitForCompletion() call returns the publish has completed
  • deliveryComplete() is used with the asynchronous publish method to notify the app when the delivery of the message is complete.
i,e. they both solve the same problem but in different ways - one blocks and the other does not.

Messages can be published in the callbacks such as the messageArrived() callback but the implementation of the callback must return promptly and not use a blocking call.  Hence waitForCompletion() must not be used in the messageArrived() callback.   If the message is published from the messageArrived() callback  without the use of waitForCompltion() then the deliveryComplete() method will be notified when delivery is complete. If this is not the case it is a bug.

All the best
Dave Locke

Senior Inventor, Pervasive and Advanced Messaging Technologies

locke@xxxxxxxxxx
Dave Locke/UK/IBM@ibmgb
7-246165 (int) +44 1962816165 (ext)
37274133 (mobex) +44 7764132584 (ext)

Fringe Bluepages with fuel injection
My Cattail: Share files in IBM and save your in-box


 



From:        Jianing Ren <jianingr@xxxxxxxxxxxx>
To:        paho-dev@xxxxxxxxxxx
Date:        28/11/2013 23:56
Subject:        [paho-dev] Hi Paho team.
Sent by:        paho-dev-bounces@xxxxxxxxxxx




Hi Paho team,


I am not sure if it counts as a bug in mqtt Java client implementation that is when I publish the topic and calling waitforcompletion(), If this topic was published from messageArrived call back method. I will never get the completeDelivery call back again. And it seems  got block unless the published message I sent in the messageArrived() call back was un other thread.


For example:
public void send(Topic topic){
token = topic.publish();
token.waitforcompletion();
}



public void completeDelivery(Token){
printout(token.getmessageID());
}



public void messageArrived(message){
….have received message

..now send back reply.
send("reply"); …This reply message will be blocked and never call "completeDelivery".
Thread thread = new thread();

thread.start
{
send("reply"); If reply sending in other thread, then worked.
}

}


Thanks.


Regards,

Jianing Ren








This email has been processed by SmoothZap -
www.smoothwall.net
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/paho-dev


Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Back to the top