You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by Yunze Xu <yz...@streamnative.io.INVALID> on 2022/12/16 07:58:54 UTC
[DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Hi all,
I've opened a PIP to discuss: https://github.com/apache/pulsar/issues/18950
Currently the `MessageId` interface is not friendly to developers of
Pulsar core and ecosystems. There is no abstraction of the
`MessageIdData` defined in `PulsarApi.proto`.
This proposal aims at solving this problem and allows more loose type
assertions when using `seek` and `acknowledge`.
You can also see the demo for reference:
https://github.com/BewareMyPower/pulsar/pull/11
(Sorry I forgot to add the [DISCUSS] prefix again in the previous
email, let's continue the discussion here)
Thanks,
Yunze
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by Yunze Xu <yz...@streamnative.io.INVALID>.
Hi Penghui,
It makes sense to me. I updated the proposal and added the API docs to
the `MessageIdAdv`, as well as why will `BatchMessageAcker` be
deprecated.
Thanks,
Yunze
On Mon, Dec 19, 2022 at 12:57 PM PengHui Li <pe...@apache.org> wrote:
>
> Hi Yunze,
>
> Thanks for the explanation. Now I understand why the BatchMessageAcker will
> be deprecated.
> For the interface face. I just thought they were for different users.
>
> For common users, they can only use MessageID.
> For advanced users (Pulsar ecosystem developers, client developers), they
> can use MessageIdAdv if needed.
>
> Thanks,
> Penghui
>
> On Mon, Dec 19, 2022 at 11:45 AM Yunze Xu <yz...@streamnative.io.invalid>
> wrote:
>
> > Hi Penghui,
> >
> > > It looks like LedgerHandleAdv to LedgerHandle in the bookkeeper.
> >
> > It's different. IMO, LedgerHandleAdv to LedgerHandle, or
> > MetadataStoreExtended to MetadataStoreExtend, are both added just to
> > avoid adding non-default methods to the original interface. But the
> > PulsarApiMessageId here has a more specific meaning that it represents
> > the proto.MessageIdData. I've thought about using the name
> > `MessageIdData`, but it could make some code complicated because both
> > these two `MessageIdData` could be used in the same file, which means
> > we have to write the very long type package name when using one of
> > them.
> >
> > > Why do we need to deprecate the BatchMessageAcker?
> >
> > Sorry I didn't make it clear. It's because if we still uses a
> > BatchMessageAcker in BatchMessageIdImpl, we still needs to use type
> > cast to call getAcker():
> >
> > ```java
> > if (msgId instanceof BatchMessageIdImpl) {
> > ((BatchMessageIdImpl) msgId).getAcker().ackIndividual();
> > }
> > ```
> >
> > Actually this proposal adds a new method to represent the ack set:
> >
> > ```java
> > default @Nullable BitSet getAckSet() {
> > return null;
> > }
> > ```
> >
> > We can replace the BatchMessageAcker with the BitSet and the batch
> > size. The introduction of the BatchMessageAcker also makes code more
> > complicated, e.g. the `getOriginalBatchSize` and `getBatchSize`
> > methods in `BatchMessageIdImpl`.
> >
> > Thanks,
> > Yunze
> >
> > On Mon, Dec 19, 2022 at 9:35 AM PengHui Li <pe...@apache.org> wrote:
> > >
> > > I agree with the motivation.
> > >
> > > Just some minor suggestions:
> > >
> > > Is AdvancedMessageId or MessageIdAdv better for this case to replace
> > > PulsarApiMessageId?
> > > It looks like LedgerHandleAdv to LedgerHandle in the bookkeeper.
> > >
> > > > We have to deprecated the BatchMessageAcker, which is just a wrapper
> > of a
> > > BitSet and the batch size.
> > >
> > > Why do we need to deprecate the BatchMessageAcker?
> > > Not all users enable batch index ack. We are using BatchMessageAcker to
> > > track if all the messages of a batch
> > > have been acked.
> > >
> > > Thanks,
> > > Penghui
> > >
> > >
> > > On Sun, Dec 18, 2022 at 3:45 PM 丛搏 <bo...@apache.org> wrote:
> > >
> > > > < For a single-topic consumer, wrapping the topic name is
> > > > < redundant and might break the existing behavior. In this case, if
> > > > < `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > > < method should return null, which is not a good design [1][2].
> > > >
> > > > For `TopicMessageIdImpl`, it is an original method. for
> > > > `PulsarApiMessageId` if extend `TopicMessageId` it is a new method for
> > > > any `MessageId` extend `PulsarApiMessageId`, why do we have to return
> > > > null? I think it just reduces the transmission of useless fields at
> > > > the network layer and not added to MessageIdData. LedgerId and EntryId
> > > > are in PulsarApiMessageId, why shouldn't `topicName` be added in?
> > > >
> > > > Thanks,
> > > > Bo
> > > >
> > > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月18日周日 14:23写道:
> > > > >
> > > > > Hi Bo,
> > > > >
> > > > > Because the topic name is not a part of MessageIdData. It's only used
> > > > > to find the correct internal consumer of a multi-topics consumer.
> > > > >
> > > > > > All I can think of is PulsarApiMessageId extend
> > > > TopicMessageId(PIP-224[1]) right?
> > > > >
> > > > > No. The `TopicMessageId` could only be used in a multi-topics
> > > > > consumer. For a single-topic consumer, wrapping the topic name is
> > > > > redundant and might break the existing behavior. In this case, if
> > > > > `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > > > method should return null, which is not a good design [1][2].
> > > > >
> > > > > After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
> > > > > will implement both `PulsarApiMessageId` and `TopicMessageId`
> > > > > interfaces. Other `MessageId` implementations only need to implement
> > > > > `PulsarApiMessageId`.
> > > > >
> > > > > BTW, PIP-224 mainly solves two problems:
> > > > > 1. When a multi-topics consumer acknowledges a `MessageId` that is
> > not
> > > > > a `TopicMessageId`, a `PulsarClientException.NotAllowedException`
> > will
> > > > > be thrown in synchronous methods. The asynchronous methods should not
> > > > > throw an exception.
> > > > > 2. For a multi-topics consumer, support seeking with a
> > `TopicMessageId`.
> > > > >
> > > > > PIP-224 is designed for application users to specify an associated
> > > > > topic name when using a `MessageId` in `seek` or `acknowledge` on a
> > > > > multi-topics consumer. PIP-229 is more like a refactoring to allow
> > the
> > > > > experienced developers access the fields of `MessageIdData` via a
> > > > > standard interface.
> > > > >
> > > > > [1]
> > > > https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
> > > > > [2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
> > > > >
> > > > > Thanks,
> > > > > Yunze
> > > > >
> > > > >
> > > > > On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
> > > > > >
> > > > > > Abstraction based on MessageIdData is a good solution. I don't have
> > > > > > any discussion context. Why don't we put the topic name in it?
> > > > > >
> > > > > > All I can think of is PulsarApiMessageId extend
> > > > > > TopicMessageId(PIP-224[1]) right?
> > > > > >
> > > > > > Thanks,
> > > > > > Bo
> > > > > > [1] https://github.com/apache/pulsar/issues/18616
> > > > > >
> > > > > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> > > > > > >
> > > > > > > Hi all,
> > > > > > >
> > > > > > > I've opened a PIP to discuss:
> > > > https://github.com/apache/pulsar/issues/18950
> > > > > > >
> > > > > > > Currently the `MessageId` interface is not friendly to
> > developers of
> > > > > > > Pulsar core and ecosystems. There is no abstraction of the
> > > > > > > `MessageIdData` defined in `PulsarApi.proto`.
> > > > > > >
> > > > > > > This proposal aims at solving this problem and allows more loose
> > type
> > > > > > > assertions when using `seek` and `acknowledge`.
> > > > > > >
> > > > > > > You can also see the demo for reference:
> > > > > > > https://github.com/BewareMyPower/pulsar/pull/11
> > > > > > >
> > > > > > > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > > > > > > email, let's continue the discussion here)
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Yunze
> > > >
> >
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by PengHui Li <pe...@apache.org>.
Hi Yunze,
Thanks for the explanation. Now I understand why the BatchMessageAcker will
be deprecated.
For the interface face. I just thought they were for different users.
For common users, they can only use MessageID.
For advanced users (Pulsar ecosystem developers, client developers), they
can use MessageIdAdv if needed.
Thanks,
Penghui
On Mon, Dec 19, 2022 at 11:45 AM Yunze Xu <yz...@streamnative.io.invalid>
wrote:
> Hi Penghui,
>
> > It looks like LedgerHandleAdv to LedgerHandle in the bookkeeper.
>
> It's different. IMO, LedgerHandleAdv to LedgerHandle, or
> MetadataStoreExtended to MetadataStoreExtend, are both added just to
> avoid adding non-default methods to the original interface. But the
> PulsarApiMessageId here has a more specific meaning that it represents
> the proto.MessageIdData. I've thought about using the name
> `MessageIdData`, but it could make some code complicated because both
> these two `MessageIdData` could be used in the same file, which means
> we have to write the very long type package name when using one of
> them.
>
> > Why do we need to deprecate the BatchMessageAcker?
>
> Sorry I didn't make it clear. It's because if we still uses a
> BatchMessageAcker in BatchMessageIdImpl, we still needs to use type
> cast to call getAcker():
>
> ```java
> if (msgId instanceof BatchMessageIdImpl) {
> ((BatchMessageIdImpl) msgId).getAcker().ackIndividual();
> }
> ```
>
> Actually this proposal adds a new method to represent the ack set:
>
> ```java
> default @Nullable BitSet getAckSet() {
> return null;
> }
> ```
>
> We can replace the BatchMessageAcker with the BitSet and the batch
> size. The introduction of the BatchMessageAcker also makes code more
> complicated, e.g. the `getOriginalBatchSize` and `getBatchSize`
> methods in `BatchMessageIdImpl`.
>
> Thanks,
> Yunze
>
> On Mon, Dec 19, 2022 at 9:35 AM PengHui Li <pe...@apache.org> wrote:
> >
> > I agree with the motivation.
> >
> > Just some minor suggestions:
> >
> > Is AdvancedMessageId or MessageIdAdv better for this case to replace
> > PulsarApiMessageId?
> > It looks like LedgerHandleAdv to LedgerHandle in the bookkeeper.
> >
> > > We have to deprecated the BatchMessageAcker, which is just a wrapper
> of a
> > BitSet and the batch size.
> >
> > Why do we need to deprecate the BatchMessageAcker?
> > Not all users enable batch index ack. We are using BatchMessageAcker to
> > track if all the messages of a batch
> > have been acked.
> >
> > Thanks,
> > Penghui
> >
> >
> > On Sun, Dec 18, 2022 at 3:45 PM 丛搏 <bo...@apache.org> wrote:
> >
> > > < For a single-topic consumer, wrapping the topic name is
> > > < redundant and might break the existing behavior. In this case, if
> > > < `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > < method should return null, which is not a good design [1][2].
> > >
> > > For `TopicMessageIdImpl`, it is an original method. for
> > > `PulsarApiMessageId` if extend `TopicMessageId` it is a new method for
> > > any `MessageId` extend `PulsarApiMessageId`, why do we have to return
> > > null? I think it just reduces the transmission of useless fields at
> > > the network layer and not added to MessageIdData. LedgerId and EntryId
> > > are in PulsarApiMessageId, why shouldn't `topicName` be added in?
> > >
> > > Thanks,
> > > Bo
> > >
> > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月18日周日 14:23写道:
> > > >
> > > > Hi Bo,
> > > >
> > > > Because the topic name is not a part of MessageIdData. It's only used
> > > > to find the correct internal consumer of a multi-topics consumer.
> > > >
> > > > > All I can think of is PulsarApiMessageId extend
> > > TopicMessageId(PIP-224[1]) right?
> > > >
> > > > No. The `TopicMessageId` could only be used in a multi-topics
> > > > consumer. For a single-topic consumer, wrapping the topic name is
> > > > redundant and might break the existing behavior. In this case, if
> > > > `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > > method should return null, which is not a good design [1][2].
> > > >
> > > > After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
> > > > will implement both `PulsarApiMessageId` and `TopicMessageId`
> > > > interfaces. Other `MessageId` implementations only need to implement
> > > > `PulsarApiMessageId`.
> > > >
> > > > BTW, PIP-224 mainly solves two problems:
> > > > 1. When a multi-topics consumer acknowledges a `MessageId` that is
> not
> > > > a `TopicMessageId`, a `PulsarClientException.NotAllowedException`
> will
> > > > be thrown in synchronous methods. The asynchronous methods should not
> > > > throw an exception.
> > > > 2. For a multi-topics consumer, support seeking with a
> `TopicMessageId`.
> > > >
> > > > PIP-224 is designed for application users to specify an associated
> > > > topic name when using a `MessageId` in `seek` or `acknowledge` on a
> > > > multi-topics consumer. PIP-229 is more like a refactoring to allow
> the
> > > > experienced developers access the fields of `MessageIdData` via a
> > > > standard interface.
> > > >
> > > > [1]
> > > https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
> > > > [2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
> > > >
> > > > Thanks,
> > > > Yunze
> > > >
> > > >
> > > > On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
> > > > >
> > > > > Abstraction based on MessageIdData is a good solution. I don't have
> > > > > any discussion context. Why don't we put the topic name in it?
> > > > >
> > > > > All I can think of is PulsarApiMessageId extend
> > > > > TopicMessageId(PIP-224[1]) right?
> > > > >
> > > > > Thanks,
> > > > > Bo
> > > > > [1] https://github.com/apache/pulsar/issues/18616
> > > > >
> > > > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> > > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I've opened a PIP to discuss:
> > > https://github.com/apache/pulsar/issues/18950
> > > > > >
> > > > > > Currently the `MessageId` interface is not friendly to
> developers of
> > > > > > Pulsar core and ecosystems. There is no abstraction of the
> > > > > > `MessageIdData` defined in `PulsarApi.proto`.
> > > > > >
> > > > > > This proposal aims at solving this problem and allows more loose
> type
> > > > > > assertions when using `seek` and `acknowledge`.
> > > > > >
> > > > > > You can also see the demo for reference:
> > > > > > https://github.com/BewareMyPower/pulsar/pull/11
> > > > > >
> > > > > > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > > > > > email, let's continue the discussion here)
> > > > > >
> > > > > > Thanks,
> > > > > > Yunze
> > >
>
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by Yunze Xu <yz...@streamnative.io.INVALID>.
Hi Penghui,
> It looks like LedgerHandleAdv to LedgerHandle in the bookkeeper.
It's different. IMO, LedgerHandleAdv to LedgerHandle, or
MetadataStoreExtended to MetadataStoreExtend, are both added just to
avoid adding non-default methods to the original interface. But the
PulsarApiMessageId here has a more specific meaning that it represents
the proto.MessageIdData. I've thought about using the name
`MessageIdData`, but it could make some code complicated because both
these two `MessageIdData` could be used in the same file, which means
we have to write the very long type package name when using one of
them.
> Why do we need to deprecate the BatchMessageAcker?
Sorry I didn't make it clear. It's because if we still uses a
BatchMessageAcker in BatchMessageIdImpl, we still needs to use type
cast to call getAcker():
```java
if (msgId instanceof BatchMessageIdImpl) {
((BatchMessageIdImpl) msgId).getAcker().ackIndividual();
}
```
Actually this proposal adds a new method to represent the ack set:
```java
default @Nullable BitSet getAckSet() {
return null;
}
```
We can replace the BatchMessageAcker with the BitSet and the batch
size. The introduction of the BatchMessageAcker also makes code more
complicated, e.g. the `getOriginalBatchSize` and `getBatchSize`
methods in `BatchMessageIdImpl`.
Thanks,
Yunze
On Mon, Dec 19, 2022 at 9:35 AM PengHui Li <pe...@apache.org> wrote:
>
> I agree with the motivation.
>
> Just some minor suggestions:
>
> Is AdvancedMessageId or MessageIdAdv better for this case to replace
> PulsarApiMessageId?
> It looks like LedgerHandleAdv to LedgerHandle in the bookkeeper.
>
> > We have to deprecated the BatchMessageAcker, which is just a wrapper of a
> BitSet and the batch size.
>
> Why do we need to deprecate the BatchMessageAcker?
> Not all users enable batch index ack. We are using BatchMessageAcker to
> track if all the messages of a batch
> have been acked.
>
> Thanks,
> Penghui
>
>
> On Sun, Dec 18, 2022 at 3:45 PM 丛搏 <bo...@apache.org> wrote:
>
> > < For a single-topic consumer, wrapping the topic name is
> > < redundant and might break the existing behavior. In this case, if
> > < `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > < method should return null, which is not a good design [1][2].
> >
> > For `TopicMessageIdImpl`, it is an original method. for
> > `PulsarApiMessageId` if extend `TopicMessageId` it is a new method for
> > any `MessageId` extend `PulsarApiMessageId`, why do we have to return
> > null? I think it just reduces the transmission of useless fields at
> > the network layer and not added to MessageIdData. LedgerId and EntryId
> > are in PulsarApiMessageId, why shouldn't `topicName` be added in?
> >
> > Thanks,
> > Bo
> >
> > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月18日周日 14:23写道:
> > >
> > > Hi Bo,
> > >
> > > Because the topic name is not a part of MessageIdData. It's only used
> > > to find the correct internal consumer of a multi-topics consumer.
> > >
> > > > All I can think of is PulsarApiMessageId extend
> > TopicMessageId(PIP-224[1]) right?
> > >
> > > No. The `TopicMessageId` could only be used in a multi-topics
> > > consumer. For a single-topic consumer, wrapping the topic name is
> > > redundant and might break the existing behavior. In this case, if
> > > `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > method should return null, which is not a good design [1][2].
> > >
> > > After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
> > > will implement both `PulsarApiMessageId` and `TopicMessageId`
> > > interfaces. Other `MessageId` implementations only need to implement
> > > `PulsarApiMessageId`.
> > >
> > > BTW, PIP-224 mainly solves two problems:
> > > 1. When a multi-topics consumer acknowledges a `MessageId` that is not
> > > a `TopicMessageId`, a `PulsarClientException.NotAllowedException` will
> > > be thrown in synchronous methods. The asynchronous methods should not
> > > throw an exception.
> > > 2. For a multi-topics consumer, support seeking with a `TopicMessageId`.
> > >
> > > PIP-224 is designed for application users to specify an associated
> > > topic name when using a `MessageId` in `seek` or `acknowledge` on a
> > > multi-topics consumer. PIP-229 is more like a refactoring to allow the
> > > experienced developers access the fields of `MessageIdData` via a
> > > standard interface.
> > >
> > > [1]
> > https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
> > > [2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
> > >
> > > Thanks,
> > > Yunze
> > >
> > >
> > > On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
> > > >
> > > > Abstraction based on MessageIdData is a good solution. I don't have
> > > > any discussion context. Why don't we put the topic name in it?
> > > >
> > > > All I can think of is PulsarApiMessageId extend
> > > > TopicMessageId(PIP-224[1]) right?
> > > >
> > > > Thanks,
> > > > Bo
> > > > [1] https://github.com/apache/pulsar/issues/18616
> > > >
> > > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> > > > >
> > > > > Hi all,
> > > > >
> > > > > I've opened a PIP to discuss:
> > https://github.com/apache/pulsar/issues/18950
> > > > >
> > > > > Currently the `MessageId` interface is not friendly to developers of
> > > > > Pulsar core and ecosystems. There is no abstraction of the
> > > > > `MessageIdData` defined in `PulsarApi.proto`.
> > > > >
> > > > > This proposal aims at solving this problem and allows more loose type
> > > > > assertions when using `seek` and `acknowledge`.
> > > > >
> > > > > You can also see the demo for reference:
> > > > > https://github.com/BewareMyPower/pulsar/pull/11
> > > > >
> > > > > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > > > > email, let's continue the discussion here)
> > > > >
> > > > > Thanks,
> > > > > Yunze
> >
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by PengHui Li <pe...@apache.org>.
I agree with the motivation.
Just some minor suggestions:
Is AdvancedMessageId or MessageIdAdv better for this case to replace
PulsarApiMessageId?
It looks like LedgerHandleAdv to LedgerHandle in the bookkeeper.
> We have to deprecated the BatchMessageAcker, which is just a wrapper of a
BitSet and the batch size.
Why do we need to deprecate the BatchMessageAcker?
Not all users enable batch index ack. We are using BatchMessageAcker to
track if all the messages of a batch
have been acked.
Thanks,
Penghui
On Sun, Dec 18, 2022 at 3:45 PM 丛搏 <bo...@apache.org> wrote:
> < For a single-topic consumer, wrapping the topic name is
> < redundant and might break the existing behavior. In this case, if
> < `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> < method should return null, which is not a good design [1][2].
>
> For `TopicMessageIdImpl`, it is an original method. for
> `PulsarApiMessageId` if extend `TopicMessageId` it is a new method for
> any `MessageId` extend `PulsarApiMessageId`, why do we have to return
> null? I think it just reduces the transmission of useless fields at
> the network layer and not added to MessageIdData. LedgerId and EntryId
> are in PulsarApiMessageId, why shouldn't `topicName` be added in?
>
> Thanks,
> Bo
>
> Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月18日周日 14:23写道:
> >
> > Hi Bo,
> >
> > Because the topic name is not a part of MessageIdData. It's only used
> > to find the correct internal consumer of a multi-topics consumer.
> >
> > > All I can think of is PulsarApiMessageId extend
> TopicMessageId(PIP-224[1]) right?
> >
> > No. The `TopicMessageId` could only be used in a multi-topics
> > consumer. For a single-topic consumer, wrapping the topic name is
> > redundant and might break the existing behavior. In this case, if
> > `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > method should return null, which is not a good design [1][2].
> >
> > After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
> > will implement both `PulsarApiMessageId` and `TopicMessageId`
> > interfaces. Other `MessageId` implementations only need to implement
> > `PulsarApiMessageId`.
> >
> > BTW, PIP-224 mainly solves two problems:
> > 1. When a multi-topics consumer acknowledges a `MessageId` that is not
> > a `TopicMessageId`, a `PulsarClientException.NotAllowedException` will
> > be thrown in synchronous methods. The asynchronous methods should not
> > throw an exception.
> > 2. For a multi-topics consumer, support seeking with a `TopicMessageId`.
> >
> > PIP-224 is designed for application users to specify an associated
> > topic name when using a `MessageId` in `seek` or `acknowledge` on a
> > multi-topics consumer. PIP-229 is more like a refactoring to allow the
> > experienced developers access the fields of `MessageIdData` via a
> > standard interface.
> >
> > [1]
> https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
> > [2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
> >
> > Thanks,
> > Yunze
> >
> >
> > On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
> > >
> > > Abstraction based on MessageIdData is a good solution. I don't have
> > > any discussion context. Why don't we put the topic name in it?
> > >
> > > All I can think of is PulsarApiMessageId extend
> > > TopicMessageId(PIP-224[1]) right?
> > >
> > > Thanks,
> > > Bo
> > > [1] https://github.com/apache/pulsar/issues/18616
> > >
> > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> > > >
> > > > Hi all,
> > > >
> > > > I've opened a PIP to discuss:
> https://github.com/apache/pulsar/issues/18950
> > > >
> > > > Currently the `MessageId` interface is not friendly to developers of
> > > > Pulsar core and ecosystems. There is no abstraction of the
> > > > `MessageIdData` defined in `PulsarApi.proto`.
> > > >
> > > > This proposal aims at solving this problem and allows more loose type
> > > > assertions when using `seek` and `acknowledge`.
> > > >
> > > > You can also see the demo for reference:
> > > > https://github.com/BewareMyPower/pulsar/pull/11
> > > >
> > > > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > > > email, let's continue the discussion here)
> > > >
> > > > Thanks,
> > > > Yunze
>
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by 丛搏 <bo...@apache.org>.
Hi, Yunze
> This interface is introduced mainly because we
> don't have a String parameter in seek and acknowledge before. It's a
> tradeoff between compatibility and complexity.
I think `MessageIdAdv` and adding `topic name` is more confusing for
non-partition-topic and redundant. If we don't couple TopicName and
MessageID together, It is better to change our interface design into
two parameters (topic name, MessageId). This is clearer and more
intuitive, and it is easier for users to understand MessageId.
MessageId also becomes simpler. I will sync this point to
PIP-224-DISCUSS [0].
I don't have any problem with this pip now, thanks for your reply.
+1 (non-binding)
Thanks,
Bo
[0] https://lists.apache.org/thread/jhqy65cdyxzmmxnfsjm8rv9pbk76noxy
Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月20日周二 15:27写道:
>
> Hi Bo,
>
> > But when `topicName` is not in the `PulsarApiMessageId`, they should use `messageId instanceof TopicMessageId` to get the `topicName`
>
> The scenario only happens for `acknowledge` APIs because I don't want
> to add more overloads in PIP-224. The new `seek` overloads in PIP-224
> just accept the `TopicMessageId` parameter.
>
> Combining the PIP-224 and PIP-229, the code will look like:
>
> ```java
> // MultiTopicsConsumerImpl
> void acknowledge(MessageId msgId) {
> if (!(msgId instanceof TopicMessageId)) {
> throw new PulsarClientException.NotAllowedException("");
> }
> consumers.get(((TopicMessageId) msgId).getOwnerTopic()).acknowledge(msgId);
> }
> void seek(TopicMessageId topicMessageId) {
> consumers.get(topicMessageId.getOwnerTopic()).seek(topicMessageId);
> }
> ```
>
> ```java
> // ConsumerImpl
> void acknowledge(MessageId msgId) {
> internalAcknowledge((MessageIdAdv) msgId); // we never need the
> owner topic now
> }
> void seek(TopicMessageId topicMessageId) {
> internalSeek((MessageIdAdv) topicMessageId);
> }
> ```
>
> That's why we need two interfaces. The use cases of TopicMessageId are
> very rare and limited. This interface is introduced mainly because we
> don't have a String parameter in seek and acknowledge before. It's a
> tradeoff between compatibility and complexity. But the use cases of
> MessageIdAdv are very common.
>
> Thanks,
> Yunze
>
> On Mon, Dec 19, 2022 at 9:00 PM 丛搏 <bo...@apache.org> wrote:
> >
> > Hi Yunze :
> >
> > I have no reason to must add the `getTopicName()` into the
> > `PulsarApiMessageId` (or named `MessageIdAdv `).
> > I just thought of a scenario that users would use. For the consumer
> > side, they don't know whether the topic is a partitioned topic or a
> > non-partitioned topic. Maybe they don't care about it. But when
> > `topicName` is not in the `PulsarApiMessageId`, they should use
> > `messageId instanceof TopicMessageId` to get the `topicName`, if this
> > `topicName` is in the `PulsarApiMessageId`, they only use the unified
> > logic to get the field from the messageId `PulsarApiMessageId
> > pulsarApiMessageId = (PulsarApiMessageId) messageId`
> >
> > These are just some of my views, and it will not block this PIP.
> >
> > Thanks,
> > Bo
> >
> > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月19日周一 10:41写道:
> > >
> > > Hi Bo,
> > >
> > > For a single-topic consumer, the MessageId implementations returned by
> > > receive() should be a MessageIdImpl or BatchedMessageIdImpl. Is there
> > > any reason to add a `getTopicName()` method for them (via extending
> > > TopicMessageId)? If yes, we have to use the default implementation of
> > > `getTopicName()` that returns null without modifying any existing
> > > code. If you don't want to return a null value, you have to add new
> > > logic that sets the topic explicitly when creating the received
> > > message.
> > >
> > > Thanks,
> > > Yunze
> > >
> > > On Sun, Dec 18, 2022 at 3:44 PM 丛搏 <bo...@apache.org> wrote:
> > > >
> > > > < For a single-topic consumer, wrapping the topic name is
> > > > < redundant and might break the existing behavior. In this case, if
> > > > < `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > > < method should return null, which is not a good design [1][2].
> > > >
> > > > For `TopicMessageIdImpl`, it is an original method. for
> > > > `PulsarApiMessageId` if extend `TopicMessageId` it is a new method for
> > > > any `MessageId` extend `PulsarApiMessageId`, why do we have to return
> > > > null? I think it just reduces the transmission of useless fields at
> > > > the network layer and not added to MessageIdData. LedgerId and EntryId
> > > > are in PulsarApiMessageId, why shouldn't `topicName` be added in?
> > > >
> > > > Thanks,
> > > > Bo
> > > >
> > > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月18日周日 14:23写道:
> > > > >
> > > > > Hi Bo,
> > > > >
> > > > > Because the topic name is not a part of MessageIdData. It's only used
> > > > > to find the correct internal consumer of a multi-topics consumer.
> > > > >
> > > > > > All I can think of is PulsarApiMessageId extend TopicMessageId(PIP-224[1]) right?
> > > > >
> > > > > No. The `TopicMessageId` could only be used in a multi-topics
> > > > > consumer. For a single-topic consumer, wrapping the topic name is
> > > > > redundant and might break the existing behavior. In this case, if
> > > > > `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > > > method should return null, which is not a good design [1][2].
> > > > >
> > > > > After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
> > > > > will implement both `PulsarApiMessageId` and `TopicMessageId`
> > > > > interfaces. Other `MessageId` implementations only need to implement
> > > > > `PulsarApiMessageId`.
> > > > >
> > > > > BTW, PIP-224 mainly solves two problems:
> > > > > 1. When a multi-topics consumer acknowledges a `MessageId` that is not
> > > > > a `TopicMessageId`, a `PulsarClientException.NotAllowedException` will
> > > > > be thrown in synchronous methods. The asynchronous methods should not
> > > > > throw an exception.
> > > > > 2. For a multi-topics consumer, support seeking with a `TopicMessageId`.
> > > > >
> > > > > PIP-224 is designed for application users to specify an associated
> > > > > topic name when using a `MessageId` in `seek` or `acknowledge` on a
> > > > > multi-topics consumer. PIP-229 is more like a refactoring to allow the
> > > > > experienced developers access the fields of `MessageIdData` via a
> > > > > standard interface.
> > > > >
> > > > > [1] https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
> > > > > [2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
> > > > >
> > > > > Thanks,
> > > > > Yunze
> > > > >
> > > > >
> > > > > On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
> > > > > >
> > > > > > Abstraction based on MessageIdData is a good solution. I don't have
> > > > > > any discussion context. Why don't we put the topic name in it?
> > > > > >
> > > > > > All I can think of is PulsarApiMessageId extend
> > > > > > TopicMessageId(PIP-224[1]) right?
> > > > > >
> > > > > > Thanks,
> > > > > > Bo
> > > > > > [1] https://github.com/apache/pulsar/issues/18616
> > > > > >
> > > > > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> > > > > > >
> > > > > > > Hi all,
> > > > > > >
> > > > > > > I've opened a PIP to discuss: https://github.com/apache/pulsar/issues/18950
> > > > > > >
> > > > > > > Currently the `MessageId` interface is not friendly to developers of
> > > > > > > Pulsar core and ecosystems. There is no abstraction of the
> > > > > > > `MessageIdData` defined in `PulsarApi.proto`.
> > > > > > >
> > > > > > > This proposal aims at solving this problem and allows more loose type
> > > > > > > assertions when using `seek` and `acknowledge`.
> > > > > > >
> > > > > > > You can also see the demo for reference:
> > > > > > > https://github.com/BewareMyPower/pulsar/pull/11
> > > > > > >
> > > > > > > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > > > > > > email, let's continue the discussion here)
> > > > > > >
> > > > > > > Thanks,
> > > > > > > Yunze
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by Yunze Xu <yz...@streamnative.io.INVALID>.
Hi Bo,
> But when `topicName` is not in the `PulsarApiMessageId`, they should use `messageId instanceof TopicMessageId` to get the `topicName`
The scenario only happens for `acknowledge` APIs because I don't want
to add more overloads in PIP-224. The new `seek` overloads in PIP-224
just accept the `TopicMessageId` parameter.
Combining the PIP-224 and PIP-229, the code will look like:
```java
// MultiTopicsConsumerImpl
void acknowledge(MessageId msgId) {
if (!(msgId instanceof TopicMessageId)) {
throw new PulsarClientException.NotAllowedException("");
}
consumers.get(((TopicMessageId) msgId).getOwnerTopic()).acknowledge(msgId);
}
void seek(TopicMessageId topicMessageId) {
consumers.get(topicMessageId.getOwnerTopic()).seek(topicMessageId);
}
```
```java
// ConsumerImpl
void acknowledge(MessageId msgId) {
internalAcknowledge((MessageIdAdv) msgId); // we never need the
owner topic now
}
void seek(TopicMessageId topicMessageId) {
internalSeek((MessageIdAdv) topicMessageId);
}
```
That's why we need two interfaces. The use cases of TopicMessageId are
very rare and limited. This interface is introduced mainly because we
don't have a String parameter in seek and acknowledge before. It's a
tradeoff between compatibility and complexity. But the use cases of
MessageIdAdv are very common.
Thanks,
Yunze
On Mon, Dec 19, 2022 at 9:00 PM 丛搏 <bo...@apache.org> wrote:
>
> Hi Yunze :
>
> I have no reason to must add the `getTopicName()` into the
> `PulsarApiMessageId` (or named `MessageIdAdv `).
> I just thought of a scenario that users would use. For the consumer
> side, they don't know whether the topic is a partitioned topic or a
> non-partitioned topic. Maybe they don't care about it. But when
> `topicName` is not in the `PulsarApiMessageId`, they should use
> `messageId instanceof TopicMessageId` to get the `topicName`, if this
> `topicName` is in the `PulsarApiMessageId`, they only use the unified
> logic to get the field from the messageId `PulsarApiMessageId
> pulsarApiMessageId = (PulsarApiMessageId) messageId`
>
> These are just some of my views, and it will not block this PIP.
>
> Thanks,
> Bo
>
> Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月19日周一 10:41写道:
> >
> > Hi Bo,
> >
> > For a single-topic consumer, the MessageId implementations returned by
> > receive() should be a MessageIdImpl or BatchedMessageIdImpl. Is there
> > any reason to add a `getTopicName()` method for them (via extending
> > TopicMessageId)? If yes, we have to use the default implementation of
> > `getTopicName()` that returns null without modifying any existing
> > code. If you don't want to return a null value, you have to add new
> > logic that sets the topic explicitly when creating the received
> > message.
> >
> > Thanks,
> > Yunze
> >
> > On Sun, Dec 18, 2022 at 3:44 PM 丛搏 <bo...@apache.org> wrote:
> > >
> > > < For a single-topic consumer, wrapping the topic name is
> > > < redundant and might break the existing behavior. In this case, if
> > > < `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > < method should return null, which is not a good design [1][2].
> > >
> > > For `TopicMessageIdImpl`, it is an original method. for
> > > `PulsarApiMessageId` if extend `TopicMessageId` it is a new method for
> > > any `MessageId` extend `PulsarApiMessageId`, why do we have to return
> > > null? I think it just reduces the transmission of useless fields at
> > > the network layer and not added to MessageIdData. LedgerId and EntryId
> > > are in PulsarApiMessageId, why shouldn't `topicName` be added in?
> > >
> > > Thanks,
> > > Bo
> > >
> > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月18日周日 14:23写道:
> > > >
> > > > Hi Bo,
> > > >
> > > > Because the topic name is not a part of MessageIdData. It's only used
> > > > to find the correct internal consumer of a multi-topics consumer.
> > > >
> > > > > All I can think of is PulsarApiMessageId extend TopicMessageId(PIP-224[1]) right?
> > > >
> > > > No. The `TopicMessageId` could only be used in a multi-topics
> > > > consumer. For a single-topic consumer, wrapping the topic name is
> > > > redundant and might break the existing behavior. In this case, if
> > > > `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > > method should return null, which is not a good design [1][2].
> > > >
> > > > After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
> > > > will implement both `PulsarApiMessageId` and `TopicMessageId`
> > > > interfaces. Other `MessageId` implementations only need to implement
> > > > `PulsarApiMessageId`.
> > > >
> > > > BTW, PIP-224 mainly solves two problems:
> > > > 1. When a multi-topics consumer acknowledges a `MessageId` that is not
> > > > a `TopicMessageId`, a `PulsarClientException.NotAllowedException` will
> > > > be thrown in synchronous methods. The asynchronous methods should not
> > > > throw an exception.
> > > > 2. For a multi-topics consumer, support seeking with a `TopicMessageId`.
> > > >
> > > > PIP-224 is designed for application users to specify an associated
> > > > topic name when using a `MessageId` in `seek` or `acknowledge` on a
> > > > multi-topics consumer. PIP-229 is more like a refactoring to allow the
> > > > experienced developers access the fields of `MessageIdData` via a
> > > > standard interface.
> > > >
> > > > [1] https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
> > > > [2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
> > > >
> > > > Thanks,
> > > > Yunze
> > > >
> > > >
> > > > On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
> > > > >
> > > > > Abstraction based on MessageIdData is a good solution. I don't have
> > > > > any discussion context. Why don't we put the topic name in it?
> > > > >
> > > > > All I can think of is PulsarApiMessageId extend
> > > > > TopicMessageId(PIP-224[1]) right?
> > > > >
> > > > > Thanks,
> > > > > Bo
> > > > > [1] https://github.com/apache/pulsar/issues/18616
> > > > >
> > > > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> > > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I've opened a PIP to discuss: https://github.com/apache/pulsar/issues/18950
> > > > > >
> > > > > > Currently the `MessageId` interface is not friendly to developers of
> > > > > > Pulsar core and ecosystems. There is no abstraction of the
> > > > > > `MessageIdData` defined in `PulsarApi.proto`.
> > > > > >
> > > > > > This proposal aims at solving this problem and allows more loose type
> > > > > > assertions when using `seek` and `acknowledge`.
> > > > > >
> > > > > > You can also see the demo for reference:
> > > > > > https://github.com/BewareMyPower/pulsar/pull/11
> > > > > >
> > > > > > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > > > > > email, let's continue the discussion here)
> > > > > >
> > > > > > Thanks,
> > > > > > Yunze
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by 丛搏 <bo...@apache.org>.
Hi Yunze :
I have no reason to must add the `getTopicName()` into the
`PulsarApiMessageId` (or named `MessageIdAdv `).
I just thought of a scenario that users would use. For the consumer
side, they don't know whether the topic is a partitioned topic or a
non-partitioned topic. Maybe they don't care about it. But when
`topicName` is not in the `PulsarApiMessageId`, they should use
`messageId instanceof TopicMessageId` to get the `topicName`, if this
`topicName` is in the `PulsarApiMessageId`, they only use the unified
logic to get the field from the messageId `PulsarApiMessageId
pulsarApiMessageId = (PulsarApiMessageId) messageId`
These are just some of my views, and it will not block this PIP.
Thanks,
Bo
Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月19日周一 10:41写道:
>
> Hi Bo,
>
> For a single-topic consumer, the MessageId implementations returned by
> receive() should be a MessageIdImpl or BatchedMessageIdImpl. Is there
> any reason to add a `getTopicName()` method for them (via extending
> TopicMessageId)? If yes, we have to use the default implementation of
> `getTopicName()` that returns null without modifying any existing
> code. If you don't want to return a null value, you have to add new
> logic that sets the topic explicitly when creating the received
> message.
>
> Thanks,
> Yunze
>
> On Sun, Dec 18, 2022 at 3:44 PM 丛搏 <bo...@apache.org> wrote:
> >
> > < For a single-topic consumer, wrapping the topic name is
> > < redundant and might break the existing behavior. In this case, if
> > < `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > < method should return null, which is not a good design [1][2].
> >
> > For `TopicMessageIdImpl`, it is an original method. for
> > `PulsarApiMessageId` if extend `TopicMessageId` it is a new method for
> > any `MessageId` extend `PulsarApiMessageId`, why do we have to return
> > null? I think it just reduces the transmission of useless fields at
> > the network layer and not added to MessageIdData. LedgerId and EntryId
> > are in PulsarApiMessageId, why shouldn't `topicName` be added in?
> >
> > Thanks,
> > Bo
> >
> > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月18日周日 14:23写道:
> > >
> > > Hi Bo,
> > >
> > > Because the topic name is not a part of MessageIdData. It's only used
> > > to find the correct internal consumer of a multi-topics consumer.
> > >
> > > > All I can think of is PulsarApiMessageId extend TopicMessageId(PIP-224[1]) right?
> > >
> > > No. The `TopicMessageId` could only be used in a multi-topics
> > > consumer. For a single-topic consumer, wrapping the topic name is
> > > redundant and might break the existing behavior. In this case, if
> > > `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > > method should return null, which is not a good design [1][2].
> > >
> > > After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
> > > will implement both `PulsarApiMessageId` and `TopicMessageId`
> > > interfaces. Other `MessageId` implementations only need to implement
> > > `PulsarApiMessageId`.
> > >
> > > BTW, PIP-224 mainly solves two problems:
> > > 1. When a multi-topics consumer acknowledges a `MessageId` that is not
> > > a `TopicMessageId`, a `PulsarClientException.NotAllowedException` will
> > > be thrown in synchronous methods. The asynchronous methods should not
> > > throw an exception.
> > > 2. For a multi-topics consumer, support seeking with a `TopicMessageId`.
> > >
> > > PIP-224 is designed for application users to specify an associated
> > > topic name when using a `MessageId` in `seek` or `acknowledge` on a
> > > multi-topics consumer. PIP-229 is more like a refactoring to allow the
> > > experienced developers access the fields of `MessageIdData` via a
> > > standard interface.
> > >
> > > [1] https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
> > > [2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
> > >
> > > Thanks,
> > > Yunze
> > >
> > >
> > > On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
> > > >
> > > > Abstraction based on MessageIdData is a good solution. I don't have
> > > > any discussion context. Why don't we put the topic name in it?
> > > >
> > > > All I can think of is PulsarApiMessageId extend
> > > > TopicMessageId(PIP-224[1]) right?
> > > >
> > > > Thanks,
> > > > Bo
> > > > [1] https://github.com/apache/pulsar/issues/18616
> > > >
> > > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> > > > >
> > > > > Hi all,
> > > > >
> > > > > I've opened a PIP to discuss: https://github.com/apache/pulsar/issues/18950
> > > > >
> > > > > Currently the `MessageId` interface is not friendly to developers of
> > > > > Pulsar core and ecosystems. There is no abstraction of the
> > > > > `MessageIdData` defined in `PulsarApi.proto`.
> > > > >
> > > > > This proposal aims at solving this problem and allows more loose type
> > > > > assertions when using `seek` and `acknowledge`.
> > > > >
> > > > > You can also see the demo for reference:
> > > > > https://github.com/BewareMyPower/pulsar/pull/11
> > > > >
> > > > > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > > > > email, let's continue the discussion here)
> > > > >
> > > > > Thanks,
> > > > > Yunze
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by Yunze Xu <yz...@streamnative.io.INVALID>.
Hi Bo,
For a single-topic consumer, the MessageId implementations returned by
receive() should be a MessageIdImpl or BatchedMessageIdImpl. Is there
any reason to add a `getTopicName()` method for them (via extending
TopicMessageId)? If yes, we have to use the default implementation of
`getTopicName()` that returns null without modifying any existing
code. If you don't want to return a null value, you have to add new
logic that sets the topic explicitly when creating the received
message.
Thanks,
Yunze
On Sun, Dec 18, 2022 at 3:44 PM 丛搏 <bo...@apache.org> wrote:
>
> < For a single-topic consumer, wrapping the topic name is
> < redundant and might break the existing behavior. In this case, if
> < `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> < method should return null, which is not a good design [1][2].
>
> For `TopicMessageIdImpl`, it is an original method. for
> `PulsarApiMessageId` if extend `TopicMessageId` it is a new method for
> any `MessageId` extend `PulsarApiMessageId`, why do we have to return
> null? I think it just reduces the transmission of useless fields at
> the network layer and not added to MessageIdData. LedgerId and EntryId
> are in PulsarApiMessageId, why shouldn't `topicName` be added in?
>
> Thanks,
> Bo
>
> Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月18日周日 14:23写道:
> >
> > Hi Bo,
> >
> > Because the topic name is not a part of MessageIdData. It's only used
> > to find the correct internal consumer of a multi-topics consumer.
> >
> > > All I can think of is PulsarApiMessageId extend TopicMessageId(PIP-224[1]) right?
> >
> > No. The `TopicMessageId` could only be used in a multi-topics
> > consumer. For a single-topic consumer, wrapping the topic name is
> > redundant and might break the existing behavior. In this case, if
> > `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> > method should return null, which is not a good design [1][2].
> >
> > After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
> > will implement both `PulsarApiMessageId` and `TopicMessageId`
> > interfaces. Other `MessageId` implementations only need to implement
> > `PulsarApiMessageId`.
> >
> > BTW, PIP-224 mainly solves two problems:
> > 1. When a multi-topics consumer acknowledges a `MessageId` that is not
> > a `TopicMessageId`, a `PulsarClientException.NotAllowedException` will
> > be thrown in synchronous methods. The asynchronous methods should not
> > throw an exception.
> > 2. For a multi-topics consumer, support seeking with a `TopicMessageId`.
> >
> > PIP-224 is designed for application users to specify an associated
> > topic name when using a `MessageId` in `seek` or `acknowledge` on a
> > multi-topics consumer. PIP-229 is more like a refactoring to allow the
> > experienced developers access the fields of `MessageIdData` via a
> > standard interface.
> >
> > [1] https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
> > [2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
> >
> > Thanks,
> > Yunze
> >
> >
> > On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
> > >
> > > Abstraction based on MessageIdData is a good solution. I don't have
> > > any discussion context. Why don't we put the topic name in it?
> > >
> > > All I can think of is PulsarApiMessageId extend
> > > TopicMessageId(PIP-224[1]) right?
> > >
> > > Thanks,
> > > Bo
> > > [1] https://github.com/apache/pulsar/issues/18616
> > >
> > > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> > > >
> > > > Hi all,
> > > >
> > > > I've opened a PIP to discuss: https://github.com/apache/pulsar/issues/18950
> > > >
> > > > Currently the `MessageId` interface is not friendly to developers of
> > > > Pulsar core and ecosystems. There is no abstraction of the
> > > > `MessageIdData` defined in `PulsarApi.proto`.
> > > >
> > > > This proposal aims at solving this problem and allows more loose type
> > > > assertions when using `seek` and `acknowledge`.
> > > >
> > > > You can also see the demo for reference:
> > > > https://github.com/BewareMyPower/pulsar/pull/11
> > > >
> > > > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > > > email, let's continue the discussion here)
> > > >
> > > > Thanks,
> > > > Yunze
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by 丛搏 <bo...@apache.org>.
< For a single-topic consumer, wrapping the topic name is
< redundant and might break the existing behavior. In this case, if
< `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
< method should return null, which is not a good design [1][2].
For `TopicMessageIdImpl`, it is an original method. for
`PulsarApiMessageId` if extend `TopicMessageId` it is a new method for
any `MessageId` extend `PulsarApiMessageId`, why do we have to return
null? I think it just reduces the transmission of useless fields at
the network layer and not added to MessageIdData. LedgerId and EntryId
are in PulsarApiMessageId, why shouldn't `topicName` be added in?
Thanks,
Bo
Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月18日周日 14:23写道:
>
> Hi Bo,
>
> Because the topic name is not a part of MessageIdData. It's only used
> to find the correct internal consumer of a multi-topics consumer.
>
> > All I can think of is PulsarApiMessageId extend TopicMessageId(PIP-224[1]) right?
>
> No. The `TopicMessageId` could only be used in a multi-topics
> consumer. For a single-topic consumer, wrapping the topic name is
> redundant and might break the existing behavior. In this case, if
> `PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
> method should return null, which is not a good design [1][2].
>
> After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
> will implement both `PulsarApiMessageId` and `TopicMessageId`
> interfaces. Other `MessageId` implementations only need to implement
> `PulsarApiMessageId`.
>
> BTW, PIP-224 mainly solves two problems:
> 1. When a multi-topics consumer acknowledges a `MessageId` that is not
> a `TopicMessageId`, a `PulsarClientException.NotAllowedException` will
> be thrown in synchronous methods. The asynchronous methods should not
> throw an exception.
> 2. For a multi-topics consumer, support seeking with a `TopicMessageId`.
>
> PIP-224 is designed for application users to specify an associated
> topic name when using a `MessageId` in `seek` or `acknowledge` on a
> multi-topics consumer. PIP-229 is more like a refactoring to allow the
> experienced developers access the fields of `MessageIdData` via a
> standard interface.
>
> [1] https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
> [2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
>
> Thanks,
> Yunze
>
>
> On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
> >
> > Abstraction based on MessageIdData is a good solution. I don't have
> > any discussion context. Why don't we put the topic name in it?
> >
> > All I can think of is PulsarApiMessageId extend
> > TopicMessageId(PIP-224[1]) right?
> >
> > Thanks,
> > Bo
> > [1] https://github.com/apache/pulsar/issues/18616
> >
> > Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> > >
> > > Hi all,
> > >
> > > I've opened a PIP to discuss: https://github.com/apache/pulsar/issues/18950
> > >
> > > Currently the `MessageId` interface is not friendly to developers of
> > > Pulsar core and ecosystems. There is no abstraction of the
> > > `MessageIdData` defined in `PulsarApi.proto`.
> > >
> > > This proposal aims at solving this problem and allows more loose type
> > > assertions when using `seek` and `acknowledge`.
> > >
> > > You can also see the demo for reference:
> > > https://github.com/BewareMyPower/pulsar/pull/11
> > >
> > > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > > email, let's continue the discussion here)
> > >
> > > Thanks,
> > > Yunze
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by Yunze Xu <yz...@streamnative.io.INVALID>.
Hi Bo,
Because the topic name is not a part of MessageIdData. It's only used
to find the correct internal consumer of a multi-topics consumer.
> All I can think of is PulsarApiMessageId extend TopicMessageId(PIP-224[1]) right?
No. The `TopicMessageId` could only be used in a multi-topics
consumer. For a single-topic consumer, wrapping the topic name is
redundant and might break the existing behavior. In this case, if
`PulsarApiMessageId` extends `TopicMessageId`, the `getTopicName()`
method should return null, which is not a good design [1][2].
After both PIP-224 and PIP-229 are approved, the `TopicMessageIdImpl`
will implement both `PulsarApiMessageId` and `TopicMessageId`
interfaces. Other `MessageId` implementations only need to implement
`PulsarApiMessageId`.
BTW, PIP-224 mainly solves two problems:
1. When a multi-topics consumer acknowledges a `MessageId` that is not
a `TopicMessageId`, a `PulsarClientException.NotAllowedException` will
be thrown in synchronous methods. The asynchronous methods should not
throw an exception.
2. For a multi-topics consumer, support seeking with a `TopicMessageId`.
PIP-224 is designed for application users to specify an associated
topic name when using a `MessageId` in `seek` or `acknowledge` on a
multi-topics consumer. PIP-229 is more like a refactoring to allow the
experienced developers access the fields of `MessageIdData` via a
standard interface.
[1] https://github.com/apache/pulsar/issues/18616#issuecomment-1328609346
[2] https://lists.apache.org/thread/g8o0qtljllxnvck69dn36205xg5xr8cc
Thanks,
Yunze
On Fri, Dec 16, 2022 at 8:50 PM 丛搏 <bo...@apache.org> wrote:
>
> Abstraction based on MessageIdData is a good solution. I don't have
> any discussion context. Why don't we put the topic name in it?
>
> All I can think of is PulsarApiMessageId extend
> TopicMessageId(PIP-224[1]) right?
>
> Thanks,
> Bo
> [1] https://github.com/apache/pulsar/issues/18616
>
> Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
> >
> > Hi all,
> >
> > I've opened a PIP to discuss: https://github.com/apache/pulsar/issues/18950
> >
> > Currently the `MessageId` interface is not friendly to developers of
> > Pulsar core and ecosystems. There is no abstraction of the
> > `MessageIdData` defined in `PulsarApi.proto`.
> >
> > This proposal aims at solving this problem and allows more loose type
> > assertions when using `seek` and `acknowledge`.
> >
> > You can also see the demo for reference:
> > https://github.com/BewareMyPower/pulsar/pull/11
> >
> > (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> > email, let's continue the discussion here)
> >
> > Thanks,
> > Yunze
Re: [DISCUSS] PIP-229: Add a common interface to get fields of MessageIdData
Posted by 丛搏 <bo...@apache.org>.
Abstraction based on MessageIdData is a good solution. I don't have
any discussion context. Why don't we put the topic name in it?
All I can think of is PulsarApiMessageId extend
TopicMessageId(PIP-224[1]) right?
Thanks,
Bo
[1] https://github.com/apache/pulsar/issues/18616
Yunze Xu <yz...@streamnative.io.invalid> 于2022年12月16日周五 15:59写道:
>
> Hi all,
>
> I've opened a PIP to discuss: https://github.com/apache/pulsar/issues/18950
>
> Currently the `MessageId` interface is not friendly to developers of
> Pulsar core and ecosystems. There is no abstraction of the
> `MessageIdData` defined in `PulsarApi.proto`.
>
> This proposal aims at solving this problem and allows more loose type
> assertions when using `seek` and `acknowledge`.
>
> You can also see the demo for reference:
> https://github.com/BewareMyPower/pulsar/pull/11
>
> (Sorry I forgot to add the [DISCUSS] prefix again in the previous
> email, let's continue the discussion here)
>
> Thanks,
> Yunze