使用Fusesource mqtt-client作为mqtt客户包使用,其总共提供了三种API:
1.Blocking API(阻塞式API)
2.Future based API
3.Callback/Continuation(阻塞式API)
其中第三种Callback阻塞式是前两种的基础,可以通过前两种的源码中证明:
public FutureConnection(CallbackConnection next){
receiveFutures = new LinkedList();
receivedFrames = new LinkedList();
this.next = next;
this.next.listener(new Listener() {
public void onConnected()
{
connected = true;
}
public void onDisconnected()
{
connected = false;
}
pub