接口的使用
org.apache.pulsar.client.api.Message
使用Message的程序包
程序包
说明
Pulsar Client API.
Pulsar interceptors.
-
org.apache.pulsar.client.api中Message的使用
修饰符和类型方法说明<T> Message<T>MessagePayloadContext.asSingleMessage(MessagePayload payload, Schema<T> schema) Convert the given payload to a single message if the entry is not a batch.ConsumerInterceptor.beforeConsume(Consumer<T> consumer, Message<T> message) This is called just before the message is returned byConsumer.receive(),MessageListener.received(Consumer, Message)or theCompletableFuturereturned byConsumer.receiveAsync()completes.ReaderInterceptor.beforeRead(Reader<T> reader, Message<T> message) This is called just before the message is returned byReader.readNext(),ReaderListener.received(Reader, Message)or theCompletableFuturereturned byReader.readNextAsync()completes.ProducerInterceptor.beforeSend(Producer<T> producer, Message<T> message) 已过时。This is called fromProducer.send(Object)andProducer.sendAsync(Object)methods, before send the message to the brokers.<T> Message<T>MessagePayloadContext.getMessageAt(int index, int numMessages, MessagePayload payload, boolean containMetadata, Schema<T> schema) Get the internal single message with a specific index from a payload if the payload is a batch.Reader.readNext()Read the next message in the topic.Read the next message in the topic waiting for a maximum time.Consumer.receive()Receives a single message.Receive a single message.返回变量类型为Message的类型的org.apache.pulsar.client.api中的方法修饰符和类型方法说明Reader.readNextAsync()Read asynchronously the next message in the topic.Consumer.receiveAsync()Receive a single message参数类型为Message的org.apache.pulsar.client.api中的方法修饰符和类型方法说明default voidMessageAcknowledger.acknowledge(Message<?> message) MessageAcknowledger.acknowledgeAsync(Message<?> message) The asynchronous version ofMessageAcknowledger.acknowledge(Message).default voidMessageAcknowledger.acknowledgeCumulative(Message<?> message) default CompletableFuture<Void>MessageAcknowledger.acknowledgeCumulativeAsync(Message<?> message) The asynchronous version ofMessageAcknowledger.acknowledgeCumulative(Message).ConsumerInterceptor.beforeConsume(Consumer<T> consumer, Message<T> message) This is called just before the message is returned byConsumer.receive(),MessageListener.received(Consumer, Message)or theCompletableFuturereturned byConsumer.receiveAsync()completes.ReaderInterceptor.beforeRead(Reader<T> reader, Message<T> message) This is called just before the message is returned byReader.readNext(),ReaderListener.received(Reader, Message)or theCompletableFuturereturned byReader.readNextAsync()completes.ProducerInterceptor.beforeSend(Producer<T> producer, Message<T> message) 已过时。This is called fromProducer.send(Object)andProducer.sendAsync(Object)methods, before send the message to the brokers.default intMessageRouter.choosePartition(Message<?> msg) 已过时。since 1.22.0.default intMessageRouter.choosePartition(Message<?> msg, TopicMetadata metadata) Choose a partition based on msg and the topic metadata.voidConsumer.negativeAcknowledge(Message<?> message) Acknowledge the failure to process a single message.voidProducerInterceptor.onSendAcknowledgement(Producer<T> producer, Message<T> message, MessageId msgId, Throwable exception) 已过时。This method is called when the message sent to the broker has been acknowledged, or when sending the message fails.voidThis method is called whenever a new message is received.voidThis method is called whenever a new message is received.voidConsumer.reconsumeLater(Message<?> message, long delayTime, TimeUnit unit) reconsumeLater the consumption ofMessages.voidConsumer.reconsumeLater(Message<?> message, Map<String, String> customProperties, long delayTime, TimeUnit unit) reconsumeLater the consumption ofMessages.Consumer.reconsumeLaterAsync(Message<?> message, long delayTime, TimeUnit unit) Asynchronously reconsumeLater the consumption of a single message.Consumer.reconsumeLaterAsync(Message<?> message, Map<String, String> customProperties, long delayTime, TimeUnit unit) Asynchronously reconsumeLater the consumption of a single message.voidConsumer.reconsumeLaterCumulative(Message<?> message, long delayTime, TimeUnit unit) reconsumeLater the reception of all the messages in the stream up to (and including) the provided message.Consumer.reconsumeLaterCumulativeAsync(Message<?> message, long delayTime, TimeUnit unit) Asynchronously ReconsumeLater the reception of all the messages in the stream up to (and including) the provided message.Consumer.reconsumeLaterCumulativeAsync(Message<?> message, Map<String, String> customProperties, long delayTime, TimeUnit unit) Asynchronously ReconsumeLater the reception of all the messages in the stream up to (and including) the provided message.类型变量类型为Message的org.apache.pulsar.client.api中的方法参数修饰符和类型方法说明<T> voidMessagePayloadProcessor.process(MessagePayload payload, MessagePayloadContext context, Schema<T> schema, Consumer<Message<T>> messageConsumer) Process the message payload. -
org.apache.pulsar.client.api.interceptor中Message的使用
修饰符和类型方法说明ProducerInterceptor.beforeSend(Producer producer, Message message) This is called fromProducer.send(Object)andProducer.sendAsync(Object)methods, before send the message to the brokers.ProducerInterceptorWrapper.beforeSend(Producer producer, Message message) 修饰符和类型方法说明ProducerInterceptor.beforeSend(Producer producer, Message message) This is called fromProducer.send(Object)andProducer.sendAsync(Object)methods, before send the message to the brokers.ProducerInterceptorWrapper.beforeSend(Producer producer, Message message) booleanCheck whether the interceptor is eligible for this message.booleanvoidProducerInterceptor.onSendAcknowledgement(Producer producer, Message message, MessageId msgId, Throwable exception) This method is called when the message sent to the broker has been acknowledged, or when sending the message fails.voidProducerInterceptorWrapper.onSendAcknowledgement(Producer producer, Message message, MessageId msgId, Throwable exception)