I am trying to add producer functions to the community kafka module because we want to start pushing data to a central DB.
i am using JDK 11 and Ignition SDk 8.1.7 with the intelliJ IDE.
The functions I am adding at first look like this:
package org.ignitionmdc.apache.kafka;
import com.inductiveautomation.ignition.client.gateway_interface.ModuleRPCFactory;
import java.util.List;
import java.util.Map;
public class Kafka_Com {
public static List<Map> getConsumer(String address, String topic, String groupname) {
KafkaRPC rpc = ModuleRPCFactory.create("org.ignitionmdc.apache.kafka.kafka", KafkaRPC.class);
return rpc.RPCGetConsumer(address,topic,groupname);
}
public static List<Map> getSSLConsumer(String address, String topic, String groupname) {
KafkaRPC rpc = ModuleRPCFactory.create("org.ignitionmdc.apache.kafka.kafka", KafkaRPC.class);
return rpc.RPCGetSSLConsumer(address,topic,groupname);
}
public static String createProducer(String address){
KafkaRPC rpc = ModuleRPCFactory.create("org.ignitionmdc.apache.kafka.kafka", KafkaRPC.class);
return rpc.RPCCreateProducer(address);
}
public static boolean transmitData(String producerKey, String topic, String data){
KafkaRPC rpc = ModuleRPCFactory.create("org.ignitionmdc.apache.kafka.kafka", KafkaRPC.class);
return rpc.RPCTransmitData(producerKey, topic, data);
}
}
When I first made the module and loaded it into Ignition I could see the new functions in the doc string but I was greeted with a swath of red error text the first time I tried to call “createProducer”. I then moved back into the IDE and used the “mainTest” script as follows:
package org.ignitionmdc.apache.kafka;
public class mainTest {
public static void main(String[] args) {
Kafka_Com inst = new Kafka_Com();
String c = inst.createProducer("127.0.0.1:9092");
System.out.println(c);
}
}
The error I get is:
Exception in thread "main" java.lang.NoClassDefFoundError: com/inductiveautomation/ignition/client/gateway_interface/ModuleRPCFactory
I will of course continue to research on my own but meanwhile if anyone has faced similar I’ll appreciate any advice you can offer. Full disclosure its my 2nd day of working with java.
Thanks,
Nick