[
https://issues.apache.org/jira/browse/IGNITE-5696?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16101211#comment-16101211
]
Yujue Li commented on IGNITE-5696:
----------------------------------
import java.util.UUID;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteMessaging;
import org.apache.ignite.Ignition;
import org.apache.ignite.lang.IgniteBiPredicate;
public class IgniteMsgAsyncTest {
public static void main(String[] args) {
try (Ignite ignite = Ignition.start()) {
IgniteMessaging msg = ignite.message().withAsync();
msg.localListen("Topic", new IgniteBiPredicate<UUID,
String>() {
@Override
public boolean apply(UUID nodeId, String msg) {
try {
Thread.currentThread().sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch
block
e.printStackTrace();
}
System.out.println("Received message
[msg=" + msg + ", from=" + nodeId + ']');
return true; // Return true to continue
listening.
}
});
for (int i = 0; i < 5; i++) {
msg.send("Topic", Integer.toString(i));
System.out.println("MSG:" + i);
}
}
}
}
In the 2.0.0 version, such code can be executed correctly, but the withAsync
method is abandoned and no new solution is provided.
> A localListenAsync method is missing in the IgniteMessaging interface.
> ----------------------------------------------------------------------
>
> Key: IGNITE-5696
> URL: https://issues.apache.org/jira/browse/IGNITE-5696
> Project: Ignite
> Issue Type: Bug
> Components: messaging
> Affects Versions: 2.0
> Reporter: Yujue Li
> Fix For: 2.2
>
>
> Prior to version 2.0, the localListen method supports asynchronous mode
> because of the presence of the withAsync method.
> But in version 2.0, this is a problem because the withAsync method is
> obsolete and does not provide a localListenAsync method.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)