Hi,

I am trying to post Messages from Oracle to Kafka broker directly using custom 
java class for that I uploaded the required library in oracle and calling java 
function using oracle function/procedure. Basic java function is working fine 
but function in which Kafka is getting initialized and used throwing uncaught 
exception. Even I put whole function body inside try-catch block but still not 
getting my customized exception as message.
I am having Oracle 12C that have JVM version 1.8.

This message got popup on oracle SQL prompt at java function call 
(java.lang.NoClassDefFound Error).

I created a jar file for my custom classes and uploaded it with it's respected 
libraries to oracle DB.
I uploaded library files using below command.

loadjava -u <user>/<Password>@DB -resolve <library>.jar

Please tell how to get Kafka Producer initialized and start sending message, 
from inside oracle

My custom classes are given below

public class KafkaPublisher {
static ProducerRecord<String, String> PR = null;
static Producer<String, String> producer = null;
static Properties prop = new Properties();

public static void init() {
prop.put("bootstrap.servers", "111.11.11.11:9092");
prop.put("acks", "1");
prop.put("retries", "0");
prop.put("batch.size", "16384");
prop.put("linger.ms", "1");
prop.put("buffer.memory", "33554432");
prop.put("key.serializer", 
"org.apache.kafka.common.serialization.StringSerializer");
prop.put("value.serializer", 
"org.apache.kafka.common.serialization.StringSerializer");

}

public static String push(String data) {
String response = "No responce";
init();
try {
producer = new KafkaProducer<String, String>(prop);
PR = new ProducerRecord<String, String>("topic1", data);
Future<RecordMetadata> future = producer.send(PR);
RecordMetadata rMetaData = future.get();
response = "Current Offset: " + rMetaData.offset();
} catch (Exception e) {
response = "Message: " + e.getMessage() + " Cause: " + e.getCause();
}
return response;
}

public static String getProperties(String msg) {
return "My message: " + msg + prop.toString();
}
}

## function getProperties(String msg) is working fine but function push(String 
data) is not working.

Thanks and Regards,

Rahul Kumar
Information transmitted by this e-mail is proprietary to Mphasis, its 
associated companies and/ or its customers and is intended 
for use only by the individual or entity to which it is addressed, and may 
contain information that is privileged, confidential or 
exempt from disclosure under applicable law. If you are not the intended 
recipient or it appears that this mail has been forwarded 
to you without proper authority, you are notified that any use or dissemination 
of this information in any manner is strictly 
prohibited. In such cases, please notify us immediately at 
mailmas...@mphasis.com and delete this mail from your records.

Reply via email to