New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: multiple rlib candidates for kafka
found
#20
Comments
I think you added kafka dependency to kafka library itself. i.e. you added kafka="*" to the cargo.toml of kafka-rust library. To test the library out, you should
Let me know if this doesn't work |
Thank you so much! I followed all your steps, and add
is that means I need to delete
|
hello, yes ... that regarding the linking error: i think you'll need to have the native |
It works, thanks!!! |
this is what I put in main.rs now extern crate kafka;
use kafka::utils;
use kafka::client::KafkaClient;
fn main() {
let mut client = KafkaClient::new(vec!("localhost:9092".to_string()));
//client.load_metadata_all();
// OR
client.load_metadata(vec!("rocksdbtest".to_string())); // Loads metadata for vector of topics
let con = kafka::consumer::Consumer::new(client, "test-group".to_string(), "rocksdbtest".to_string())
.partition(0);
for msg in con {
println!("{:?}", msg);
}
} this is the warning when I type
I have .exe now, but I cannot see anything when I ran This is the tree of kafademo
|
i think we need to improve the documentation a little bit. in your particular case, however ... a) b) |
Thanks for the very detail info, xitep!!! extern crate kafka;
use kafka::client::KafkaClient;
use kafka::consumer::Consumer;
//use kafka::utils;
fn main() {
// 1. Connect to Kafka
let mut client = KafkaClient::new(vec!("localhost:9092".to_owned()));
let kafka_metadata =client.load_metadata(vec!("test".to_owned()));
// client.load_metadata(vec!("my-topic".to_owned())); //
// 2. fetch messages: single (Topic, Partition, Offset)
let offsetmsg= client.fetch_messages("test".to_owned(), 0, 0);
println!("offsetmsg: {:?}", offsetmsg);
//3. consumer
let con = Consumer::new(client, "test-consumer-group".to_owned(), "test".to_owned()).partition(0);
for msgs in con {
println!("{:?}", msgs);
}
} This is partial result
No result form the consumer. |
@Lingling7 Could you fetch the offsets for this consumer and verify that its less than the greatest offset for the partition you are consuming? |
@spicavigo Do you mean check the offset numbers (id:0-155 ) with the consumed messages numbers(as below, 156)?
In addition, the info in "messages: [91] " (mylast comment) is not the message in kafka, messages here looks like the metadata. |
@spicavigo thanks, I add this in main.rs let resp = client.fetch_group_topic_offset("test-consumer-group".to_owned(),"test".to_owned());
println!("resp: {:?}", resp); result like this |
I can use the consumer now, because I didn't set the offesetkey to the earliest, so I used
But how can I set this through rust, should I set from the consumer? For the messages form consumer, I just got the numbers, how can I get the true text messages?
And if I want to load the data to rocksdb, should I use fetch or consumer? |
The numbers in message is vector of bytes (utf-8), I need to transfer them to string
|
I'm a beginner of kafka and rust, to use rust client as a consumer, I add the github example in src/main.rs
and add
kafka = "*"
in the cargo.toml dependenciesthen I run
$ cargo build
I have the following error, is there anyone can help me to solve this?The text was updated successfully, but these errors were encountered: