问题
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.IgniteSpringHelperImpl
I don't see IgniteSpringHelperImpl 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