kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tauzell, Dave" <Dave.Tauz...@surescripts.com>
Subject RE: Using Kafka Producer inside Oracle DB
Date Thu, 06 Jul 2017 13:07:32 GMT
>> java.lang.NoClassDefFound Error

You are missing some dependent classes.   Two questions:

1. Does the message have more information about what class it couldn't find?
2. What exactly are you putting into your jar file?

-Dave

-----Original Message-----
From: Rahul R04 [mailto:Rahul.Kumar14@mphasis.com]
Sent: Thursday, July 6, 2017 5:29 AM
To: users@kafka.apache.org
Subject: Using Kafka Producer inside Oracle DB

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 mailmaster@mphasis.com and delete this mail from your records.
This e-mail and any files transmitted with it are confidential, may contain sensitive information,
and are intended solely for the use of the individual or entity to whom they are addressed.
If you have received this e-mail in error, please notify the sender by reply e-mail immediately
and destroy all copies of the e-mail and any attachments.


Mime
View raw message