camel icon indicating copy to clipboard operation
camel copied to clipboard

CAMEL-17803: Fix/reimplement automatic complete/abandon of messages

Open vachillo opened this issue 2 years ago • 4 comments

updates to manually call complete/abandon on the service bus client for a service bus consumer.

Opening to get some feedback on this, I'm unsure about some implementation details, mainly:

  • is there a better way to get the original message than saving it as an exchange property?

  • the combination of the OnConsumerCompletion.onFailure and the onErrorListener subscription on the receiveMessages.subscribe() was causing the error handler to be invoked twice, so i wasn't sure the best way to handle that.

  • I also wasn't sure how creating a custom exception handler would interact with a user-specified exception handler. would marking an exchange as handled within a custom error handler call back to the given ConsumerOnCompletion.onComplete?

  • [x] Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.

  • [ ] Each commit in the pull request should have a meaningful subject line and body.

  • [ ] If you're unsure, you can format the pull request title like [CAMEL-XXX] Fixes bug in camel-file component, where you replace CAMEL-XXX with the appropriate JIRA issue.

  • [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.

  • [ ] Run mvn clean install -Psourcecheck in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically. Below are the contribution guidelines: https://github.com/apache/camel/blob/main/CONTRIBUTING.md

vachillo avatar Mar 28 '22 17:03 vachillo

@oscerd, @vachillo , I was looking to use this camel component for dead lettering a message. https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dead-letter-queues#application-level-dead-lettering

With Azure Java SDK , we would do that as serviceBusReceiverAsyncClient.deadLetter(ServiceBusReceivedMessage message). I could not find any means to do that in the current camel version. Meanwhile, I see that the fix you are providing is very similar to this requirement.

Premcnathan avatar Apr 28 '22 10:04 Premcnathan

@davsclaus can you take a look too?

oscerd avatar Apr 29 '22 05:04 oscerd

Also it would be good to get some documentation about this change, eg maybe add a section to the doc (see src/main/docs folder) about using auto commit enabled vs disabled and how this automatic complete/abandon

davsclaus avatar Apr 29 '22 07:04 davsclaus

@vachillo thanks for providing this PR. Have you maybe already run the tests. For me they either fail:

[ERROR] org.apache.camel.component.azure.servicebus.integration.ServiceBusConsumerTest.testReceiveMessages  Time elapsed: 1.623 s  <<< FAILURE!
java.lang.AssertionError: mock://receiveMessagesResult Body of message: 0. Expected: <test batch 1> but was: <test batch 3>

Or hang:

[INFO] Running org.apache.camel.component.azure.servicebus.integration.ServiceBusProducerTest

For running tests I have first exported the 3 ENV variables below, and then:

mvn clean verify -DconnectionString=$connectionString -DtopicName=$topicName -DsubscriptionName=$subscriptionName

bvahdat avatar May 01 '22 20:05 bvahdat

I have also hit this issue. Is there any way to speed up the resolve? Also, in camel-k (yaml) I cannot set disableAutoComplete to true and manually call complete/abandon, as there is no documented way to do so. Error-Handling is currently flawed in this component

stekuth avatar Dec 28 '22 11:12 stekuth

in camel-k you can configure any camel component with its options either in modeline or a config value

davsclaus avatar Dec 28 '22 11:12 davsclaus

The PR is incomplete. You can fork the branch and start to work on it

oscerd avatar Dec 28 '22 11:12 oscerd

This has been implemented by (in other PRs) https://issues.apache.org/jira/browse/CAMEL-19155

davsclaus avatar Mar 23 '23 08:03 davsclaus