2
votes

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
Looks like it's a question of how Ignite is configured. The default config.xml includes Spring, which causes problems. I don't see now how to configure Ignite to do what I want - the documentation seem to miss this part. - J. Doe
I'm not sure anymore the default config.xml requires Spring, but the code still looks for IgniteSpringHelperImp‌​l, fails to find that and stops. The question still is how to have basic messaging using only ignite-core JAR. - J. Doe
Managed to get somewhat ahead with Ignite ignite = Ignition.start(new IgniteConfiguration()); Now it complains IgniteSpiException: Local node and remote node have different version numbers (node will not join, Ignite does not support rolling updates... Pretty cryptic as I don't have Ignite running, so no remote/local nodes to compare versions. - J. Doe
Seems like it finds an instance of Ignite running on the network. After disconnecting a worrysome message "Message queue limit is set to 0..." . Don't see how to manually set that limit to something meaningful. - J. Doe
Removing Ignition.setClientMode(true); and disconnecting allows to send messages. Complains now about this: org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException: Cluster group is empty. Can I make a brand new cluster with one node which I just started and send messages to it? - J. Doe

1 Answers

4
votes

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.