Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PIP-124] Create init subscription before sending message to DLQ #13355

Merged
merged 16 commits into from
Feb 14, 2022

Conversation

RobertIndie
Copy link
Member

@RobertIndie RobertIndie commented Dec 16, 2021

Fix #13408

Motivation

If we enable the DLQ when consuming messages. For some messages that can't be processed successfully, the messages will be moved to the DLQ, but if we do not specify the data retention for the namespace or create a subscription for the DLQ to retain the data, the data of the DLQ will be removed automatically. Therefore, we need to create the initial subscription before sending messages to the DLQ.

Modifications

When the deadLetterProducer is initialized, the consumer will set the initial subscription of the deadLetterProducer according to the DeadLetterPolicy.

When the broker creates a producer(after receiving the CommandProducer), if it finds that the topic does not exist, it will not only create the topic(if the topic automatically creation is enabled) but also create the initial subscription(if the initial subscription name is set). When creating an initial subscription, the user needs to have the canConsume permission and the allowAutoSubscriptionCreation needs to be enabled.

Verifying this change

This change is already covered by existing tests, such as
testPermissionForProducerCreateInitialSubscription
testDeadLetterTopicWithInitialSubscription

  • testDeadLetterTopicWithInitialSubscriptionAndMultiConsumers* and so on.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (yes)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

Check the box below and label this PR (if you have committer privilege).

Need to update docs?

  • doc-required

Motivation
If we enable the DLQ when consuming messages. For some messages that can't be processed successfully, the messages will be moved to the DLQ, but if we do not specify the data retention for the namespace or create a subscription for the DLQ to retain the data, the data of the DLQ topic will be removed automatically. Therefore, we need to create the initial subscription before sending messages to the DLQ.

Modification
* Add `initSubscriptionName` and `initSubscriptionType` to the `DeadLetterPolicy`
* Create the initial subscription before creating the deadLetterProducer in ConsumerImpl.

Signed-off-by: Zike Yang <ar@armail.top>
@github-actions github-actions bot added the doc-required Your PR changes impact docs and you will update later. label Dec 16, 2021
@merlimat merlimat added this to the 2.10.0 milestone Dec 16, 2021
@RobertIndie
Copy link
Member Author

@merlimat Thanks for your review. I have created a proposal for this fix: #13408. PTAL

Signed-off-by: Zike Yang <zkyang@streamnative.io>
Signed-off-by: Zike Yang <zkyang@streamnative.io>
Signed-off-by: Zike Yang <zkyang@streamnative.io>
@RobertIndie RobertIndie changed the title [WIP][Client] Create init subscription while creating DLQ producer [PIP-124] Create init subscription before sending message to DLQ Jan 27, 2022
Signed-off-by: Zike Yang <zkyang@streamnative.io>
Signed-off-by: Zike Yang <zkyang@streamnative.io>
RobertIndie added a commit to RobertIndie/pulsar that referenced this pull request Jan 28, 2022
Motivation
This PR is the doc for apache#13355

Modification
* Add doc for init sub config in DLQ policy and producer

Signed-off-by: Zike Yang <zkyang@streamnative.io>
@RobertIndie
Copy link
Member Author

/pulsarbot run-failure-checks

Signed-off-by: Zike Yang <zkyang@streamnative.io>
Signed-off-by: Zike Yang <zkyang@streamnative.io>
…xception

Signed-off-by: Zike Yang <zkyang@streamnative.io>
Signed-off-by: Zike Yang <zkyang@streamnative.io>
@hangc0276
Copy link
Contributor

/pulsarbot run-failure-checks

@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 Feb 7, 2022
@RobertIndie
Copy link
Member Author

/pulsarbot run-failure-checks

Signed-off-by: Zike Yang <zkyang@streamnative.io>
Signed-off-by: Zike Yang <zkyang@streamnative.io>
Signed-off-by: Zike Yang <zkyang@streamnative.io>
Copy link
Contributor

@Technoboy- Technoboy- left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Zike Yang <zkyang@streamnative.io>
@RobertIndie
Copy link
Member Author

/pulsarbot run-failure-checks

@codelipenghui codelipenghui merged commit 20f1ba3 into apache:master Feb 14, 2022
RobertIndie added a commit to RobertIndie/pulsar that referenced this pull request Feb 24, 2022
Motivation
In apache#13355, we added support for creating initial subscription when creating the producer. But the broker didn't check if the subscription can be created automatically. The initial subscription will be created even if the `allowAutoSubscriptionCreation` is disabled.

Modification
* Check `allowAutoSubscriptionCreation` when creating the initial subscription.

Signed-off-by: Zike Yang <zkyang@streamnative.io>
codelipenghui pushed a commit that referenced this pull request Feb 27, 2022
…#14458)

Master Issue: #13408 

### Motivation

In #13355, we added support for creating initial subscription when creating the producer. But the broker didn't check if the subscription can be created automatically. The initial subscription will be created even if the `allowAutoSubscriptionCreation` is disabled.
codelipenghui pushed a commit that referenced this pull request Mar 1, 2022
…#14458)

Master Issue: #13408

### Motivation

In #13355, we added support for creating initial subscription when creating the producer. But the broker didn't check if the subscription can be created automatically. The initial subscription will be created even if the `allowAutoSubscriptionCreation` is disabled.

(cherry picked from commit db25438)
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
…che#13355)

* fix(Client): Create init subscription while creating DLQ producer

Motivation
If we enable the DLQ when consuming messages. For some messages that can't be processed successfully, the messages will be moved to the DLQ, but if we do not specify the data retention for the namespace or create a subscription for the DLQ to retain the data, the data of the DLQ topic will be removed automatically. Therefore, we need to create the initial subscription before sending messages to the DLQ.

Modification
* Add `initSubscriptionName` and `initSubscriptionType` to the `DeadLetterPolicy`
* Create the initial subscription before creating the deadLetterProducer in ConsumerImpl.

Signed-off-by: Zike Yang <zkyang@streamnative.io>
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
…apache#14458)

Master Issue: apache#13408 

### Motivation

In apache#13355, we added support for creating initial subscription when creating the producer. But the broker didn't check if the subscription can be created automatically. The initial subscription will be created even if the `allowAutoSubscriptionCreation` is disabled.
@lhotari
Copy link
Member

lhotari commented Sep 6, 2022

What was the purpose of commit 0f202b5 "Make initialSubscriptionName internal"?

@RobertIndie
Copy link
Member Author

RobertIndie commented Sep 13, 2022

What was the purpose of commit 0f202b5 "Make initialSubscriptionName internal"?

Exposing the initialSubscriptionName property to the producer is a bit weird. From the user's perspective, the producer should not care about the subscription. So I changed it to internal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

PIP-124: Create init subscription before sending message to DLQ
8 participants