Skip to content

Conversation

@315157973
Copy link
Contributor

Motivation

See #12269

I divided this PIP into two parts, the first part supports setting properties for subscriptions
The second part will support plug-in loading, filtering, etc.

Modifications

Support add subscription properties

Documentation

  • [ x ] doc-required

@315157973 315157973 self-assigned this Nov 18, 2021
@github-actions github-actions bot added the doc-required Your PR changes impact docs and you will update later. label Nov 18, 2021
@codelipenghui
Copy link
Contributor

We have a short conversation for this PR, provide the context here.

  1. We don't need to persist the subscription properties
  2. Use a separate field for the subscription properties to distinguish the consumer metadata and subscription properties, otherwise, we need to maintain the subscription properties for each consumer.
  3. The subscription properties follow the same way as the subscription type, the subscription applies the subscription properties of the first connected consumer.

Copy link
Contributor

@Jason918 Jason918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we make the type of property value Long? Isn't String more extendable?


optional KeySharedMeta keySharedMeta = 17;

repeated KeyLongValue subscription_properties = 18;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be optional ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repeated already contains optional

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know, Thx~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be KeyValue? If use KeyLongValue, we can only use uint64 for the value.

# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java

optional KeySharedMeta keySharedMeta = 17;

repeated KeyLongValue subscription_properties = 18;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be KeyValue? If use KeyLongValue, we can only use uint64 for the value.

* @param option
* @return
*/
CompletableFuture<Consumer> subscribe(SubscriptionOption option);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we can remove the old one to avoid interface complexity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting the interface is not good, I first set it to @deprecated

this.fullName = MoreObjects.toStringHelper(this).add("topic", topicName).add("name", subName).toString();
this.expiryMonitor = new PersistentMessageExpiryMonitor(topicName, subscriptionName, cursor, this);
this.setReplicated(replicated);
this.subscriptionProperties = subscriptionProperties == null ? new HashMap<>() : subscriptionProperties;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.subscriptionProperties = subscriptionProperties == null ? new HashMap<>() : subscriptionProperties;
this.subscriptionProperties = subscriptionProperties == null ? Collections.emptyMap() : Collections.unmodifiableMap(subscriptionProperties);

Copy link
Contributor Author

@315157973 315157973 Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collections.emptyMap() is a static Map, and data may be put into this Map, so I think it is better to new

@codelipenghui codelipenghui added this to the 2.10.0 milestone Nov 22, 2021
315157973 and others added 5 commits November 22, 2021 15:25
@wolfstudy
Copy link
Member

wolfstudy commented Nov 22, 2021

@315157973 In topics stats, Do we need to display subscription properties information?

When the user sets the sub properties, how do we view the sub properties set by the user?

}

@Override
public CompletableFuture<Consumer> subscribe(final TransportCnx cnx, String subscriptionName, long consumerId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface has been marked as Deprecated, we'd better change it to private CompletableFuture<Consumer> internalSubscribe and delete @Override to avoid confusing.

void recordAddLatency(long latency, TimeUnit unit);

@Deprecated
CompletableFuture<Consumer> subscribe(TransportCnx cnx, String subscriptionName, long consumerId, SubType subType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of tests called this interface, and in order to delete it in the future, should we change the test to call the new one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I will open another PR to do this

assertEquals(properties4.get("3"), "3");
assertEquals(properties4.get("4"), "4");
consumer4.close();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. add the case: consumer subscribe without subscriptionProperties set, it will get the old one. And then restart broker, it won't get any properties?
  2. restart broker and create a new consumer with new properties, the properties will be updated. Do not restart broker and create a new consumer with new properties, the properties will be ignored. Whether the broker restart or not will not be known for consumer, does this action will confuse the consumer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit test has been added

The configuration of the Consumer is usually the same. Even if the Broker restarts and the Consumer reconnects with the original configuration, the Properties will be restored.

@315157973
Copy link
Contributor Author

@315157973 In topics stats, Do we need to display subscription properties information?

When the user sets the sub properties, how do we view the sub properties set by the user?

There are still many things to do in the future, and different PRs will be split

Copy link
Contributor

@hangc0276 hangc0276 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job.

@hangc0276 hangc0276 merged commit 6b8ebbd into apache:master Nov 24, 2021
wolfstudy added a commit that referenced this pull request Nov 29, 2021
Signed-off-by: xiaolongran <xiaolongran@tencent.com>



### Motivation

In #12869 , we introduce new filed `subscriptionProperties` in `CommandSubsctibe`. In order to better query the subscriptionProperties set by the user, we will display this property in SubscribeStats


### Modifications

- Add subscription properties for SubscriptionStats
- add test case
wolfstudy added a commit to apache/pulsar-client-go that referenced this pull request Nov 29, 2021
Signed-off-by: xiaolongran <xiaolongran@tencent.com>

### Motivation

In apache/pulsar#12869, we introduce pluggable entry filter in Dispatcher, the pull request is the Go SDK implementation of this PIP


### Modifications

*Describe the modifications you've done.*

- Add subscription properties for ConsumerOptions 
- Update `pulsarApi.proto` file
eolivelli pushed a commit to eolivelli/pulsar that referenced this pull request Nov 29, 2021
### Motivation
See apache#12269

I divided this PIP into two parts, the first part supports setting properties for subscriptions
The second part will support plug-in loading, filtering, etc.

### Modifications
Support add subscription properties
eolivelli pushed a commit to eolivelli/pulsar that referenced this pull request Nov 29, 2021
Signed-off-by: xiaolongran <xiaolongran@tencent.com>



### Motivation

In apache#12869 , we introduce new filed `subscriptionProperties` in `CommandSubsctibe`. In order to better query the subscriptionProperties set by the user, we will display this property in SubscribeStats


### Modifications

- Add subscription properties for SubscriptionStats
- add test case
fxbing pushed a commit to fxbing/pulsar that referenced this pull request Dec 19, 2021
### Motivation
See apache#12269

I divided this PIP into two parts, the first part supports setting properties for subscriptions
The second part will support plug-in loading, filtering, etc.

### Modifications
Support add subscription properties
fxbing pushed a commit to fxbing/pulsar that referenced this pull request Dec 19, 2021
Signed-off-by: xiaolongran <xiaolongran@tencent.com>



### Motivation

In apache#12869 , we introduce new filed `subscriptionProperties` in `CommandSubsctibe`. In order to better query the subscriptionProperties set by the user, we will display this property in SubscribeStats


### Modifications

- Add subscription properties for SubscriptionStats
- add test case
@Anonymitaet Anonymitaet added doc-complete Your PR changes impact docs and the related docs have been already added. and removed doc-required Your PR changes impact docs and you will update later. labels Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/broker doc-complete Your PR changes impact docs and the related docs have been already added.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants