forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use raw message when manually parsing messages from topic storage (ap…
…ache#3146) * Use raw message when manually parsing messages from topic storage * Added missing headers * Fixed copy to byte[]
- Loading branch information
Showing
12 changed files
with
447 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
pulsar-common/src/main/java/org/apache/pulsar/common/api/raw/RawMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.common.api.raw; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* View of a message that exposes the internal direct-memory buffer for more efficient processing. | ||
* | ||
* The message needs to be released when the processing is done. | ||
*/ | ||
public interface RawMessage { | ||
|
||
/** | ||
* Release all the resources associated with this raw message | ||
*/ | ||
void release(); | ||
|
||
/** | ||
* Return the properties attached to the message. | ||
* | ||
* Properties are application defined key/value pairs that will be attached to the message | ||
* | ||
* @return an unmodifiable view of the properties map | ||
*/ | ||
Map<String, String> getProperties(); | ||
|
||
/** | ||
* Get the content of the message | ||
* | ||
* @return the byte array with the message payload | ||
*/ | ||
ByteBuf getData(); | ||
|
||
/** | ||
* Get the unique message ID associated with this message. | ||
* | ||
* The message id can be used to univocally refer to a message without having the keep the entire payload in memory. | ||
* | ||
* Only messages received from the consumer will have a message id assigned. | ||
* | ||
* @return the message id null if this message was not received by this client instance | ||
*/ | ||
RawMessageId getMessageId(); | ||
|
||
/** | ||
* Get the publish time of this message. The publish time is the timestamp that a client publish the message. | ||
* | ||
* @return publish time of this message. | ||
* @see #getEventTime() | ||
*/ | ||
long getPublishTime(); | ||
|
||
/** | ||
* Get the event time associated with this message. It is typically set by the applications via | ||
* {@link MessageBuilder#setEventTime(long)}. | ||
* | ||
* <p> | ||
* If there isn't any event time associated with this event, it will return 0. | ||
*/ | ||
long getEventTime(); | ||
|
||
/** | ||
* Get the sequence id associated with this message. It is typically set by the applications via | ||
* {@link MessageBuilder#setSequenceId(long)}. | ||
* | ||
* @return sequence id associated with this message. | ||
* @see MessageBuilder#setEventTime(long) | ||
*/ | ||
long getSequenceId(); | ||
|
||
/** | ||
* Get the producer name who produced this message. | ||
* | ||
* @return producer name who produced this message, null if producer name is not set. | ||
*/ | ||
String getProducerName(); | ||
|
||
/** | ||
* Get the key of the message | ||
* | ||
* @return the key of the message | ||
*/ | ||
Optional<String> getKey(); | ||
} |
23 changes: 23 additions & 0 deletions
23
pulsar-common/src/main/java/org/apache/pulsar/common/api/raw/RawMessageId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.common.api.raw; | ||
|
||
public interface RawMessageId { | ||
|
||
} |
Oops, something went wrong.