Comments (4)
Is that the entire text of the error? That implies to me that either the consumer or the connection is going out of scope before the ack is being sent, which should be impossible. Do you have a (relatively) minimal reproduction I could take a look at?
from pulsar-rs.
use pulsar::{Pulsar, Consumer, SubType, DeserializeMessage, SerializeMessage, producer};
use serde::{Serialize, Deserialize};
use std::time::Duration;
use pulsar::Error as PulsarError;
use pulsar::message::Payload;
use futures::executor::ThreadPool;
use futures::task::SpawnExt;
use futures::compat::Stream01CompatExt;
use futures::stream::StreamExt;
use futures::compat::Future01CompatExt;
#[derive(Debug)]
enum Error {
Pulsar(PulsarError),
Message(String),
Timeout(std::io::Error),
Serde(serde_json::Error),
Utf8(std::string::FromUtf8Error),
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Timeout(e)
}
}
impl From<PulsarError> for Error {
fn from(e: PulsarError) -> Self {
Error::Pulsar(e)
}
}
impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
Error::Serde(e)
}
}
impl From<std::string::FromUtf8Error> for Error {
fn from(err: std::string::FromUtf8Error) -> Self {
Error::Utf8(err)
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Error::Pulsar(e) => write!(f, "{}", e),
Error::Message(e) => write!(f, "{}", e),
Error::Timeout(e) => write!(f, "{}", e),
Error::Serde(e) => write!(f, "{}", e),
Error::Utf8(e) => write!(f, "{}", e),
}
}
}
#[derive(Debug, Serialize, Deserialize)]
struct TestData {
pub data: String,
}
impl SerializeMessage for TestData {
fn serialize_message(input: &Self) -> Result<producer::Message, PulsarError> {
let payload =
serde_json::to_vec(input).map_err(|e| PulsarError::Custom(e.to_string()))?;
Ok(producer::Message {
payload,
..Default::default()
})
}
}
impl DeserializeMessage for TestData {
type Output = Result<TestData, serde_json::Error>;
fn deserialize_message(payload: Payload) -> Self::Output {
serde_json::from_slice(&payload.data)
}
}
async fn run() {
let addr = "127.0.0.1:6650".parse().unwrap();
let executor = ThreadPool::new().unwrap().compat();
let pulsar: Pulsar = Pulsar::new(addr, None, executor).compat().await.unwrap();
let consumer: Consumer<TestData> = pulsar
.consumer()
.with_topic("test")
.with_consumer_name("test_consumer")
.with_subscription_type(SubType::Shared)
.with_subscription("test_subscription")
.build().compat().await.unwrap();
consumer.compat().for_each(move|msg| {
let msg = msg.unwrap();
msg.ack.ack();
futures::future::ready(())
}).await;
tokio::time::delay_for(Duration::from_millis(5000)).await;
/* this will panic
let producer = pulsar.producer(None);
producer.send(
"test",
&TestData {
data: "data".to_string(),
},
).compat().await.unwrap();
*/
pulsar.send("test", &TestData {
data: "data".to_string(),
}, Default::default()).compat().await;
}
#[tokio::main]
async fn main() {
run().await;
}
from pulsar-rs.
and I changed the ack function for print the error message:
pub fn ack(mut self) {
for (consumer_id, message_ids) in self.take_message_ids() {
let result = self.sender.unbounded_send(AckMessage::Ack {
consumer_id,
message_ids,
cumulative: false,
});
if let Err(e) = result {
println!("===============ack error: {}", e.to_string());
} else {
println!("===============ack ok");
}
}
}
from pulsar-rs.
this should be fixed by the 1.0 release
from pulsar-rs.
Related Issues (20)
- Add control over compression level HOT 7
- Consumer connection is not cleaned well HOT 2
- Add a way to acknowledge a message only with Id HOT 3
- `negativeAckRedeliveryDelay` & `negativeAckRedeliveryBackoff`
- Release should update master branch metadata HOT 3
- Transaction API support HOT 3
- Library always connect to 127.0.0.1? HOT 5
- Support for consumer event listener HOT 2
- Why client redirect to ssl connection? HOT 1
- Consumer stucks in reconnections HOT 9
- Consumer `try_next` stops producing messages, but consumer is still processing messages internally
- Producer and Consumer IDs
- Limit producer batch messages by size in bytes as well HOT 2
- Connection error: bytes remaining on stream
- Timeout in batching
- Negative unackedMessages in consumers
- Unable to cleanly close a consumer without unsubscribing from a topic HOT 2
- Mutex in producer::TopicProducer is unnecessary
- Concretize types for client building
- TLS BAD_PACKET_LENGTH Error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pulsar-rs.