Ignite: using core only to have messaging?

会有一股神秘感。 提交于 2019-12-24 03:53:30

问题


I want to make a small(est) app which uses only ignite-core-2.0.0 and does Ignite messaging. There is a cluster somewhere which I want to exchange messages with.

I've set IGNITE_HOME to ./apache-ignite-2.0.0-src where I've got compiled sources. File IGNITE_HOME/config/default-config.xml exists and isn't changed.

Here is the code running before the exception

Ignition.setClientMode(true);
Ignite ignite = Ignition.start();
...

I'm getting

Exception in thread "main" class org.apache.ignite.IgniteException:
    Failed to create Ignite component (consider adding ignite-spring
    module to classpath)...

Caused by: java.lang.ClassNotFoundException:
    org.apache.ignite.internal.util.spring.IgniteSpringHelperImp‌​l

I don't see IgniteSpringHelperImp‌​l class in ignite-core JAR and wonder why it could be needed.

How to get messaging work with only ignite-core JAR?


回答1:


This looks like working so far.

IgniteConfiguration cfg = new IgniteConfiguration();
TcpDiscoverySpi spi = new TcpDiscoverySpi();
cfg.setDiscoverySpi(spi);
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1"));
spi.setIpFinder(ipFinder);
Ignite ignite = Ignition.start(cfg);
IgniteMessaging igMsg = ignite.message(ignite.cluster().forLocal());
igMsg.localListen("unorderedTopic", (nodeId, msg) -> {
    System.out.println("msg: " + msg + ", from: " + nodeId);
    return true; // to continue listening
});
for (int i = 0; i < 10; i++)
    igMsg.send("unorderedTopic", Integer.toString(i));

On my machine messages are sent and received.



来源:https://stackoverflow.com/questions/44010153/ignite-using-core-only-to-have-messaging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!