Code Monkey home page Code Monkey logo

Comments (6)

odolbeau avatar odolbeau commented on June 2, 2024

Hi

According to your configuration, processors will be called in this order:

  • signal_handler
  • exception_catcher
  • ack
  • max_messages
  • your processor
  • max_messages
  • ack
  • exception_catcher
  • signal _handler

In your case, you received message number 19. Your processor did the job, the max messages processor have been called but your still under the limit you defined. Then the ack processor did it's job.
Then, you received message number 20. Your processor did the job. The max processor have been called and as you've reached you limit it did it's job (log + prevent other message). Then ack processor have been called and ack'ed the message.

I would recommend you to use this order:

  • signal_handler
  • max_messages
  • exception_catcher
  • ack

This way:

  • Logs will be more understandable (first ack then max_messages & stop)
  • You won't have trouble with exceptions (with your actual configuration, if the message number 20 have an exception, the max messages processor won't catch the exception, which means you will process another message)

from swarrotbundle.

noniagriconomie avatar noniagriconomie commented on June 2, 2024

hi @odolbeau,

first thank for you explanations and your time.

Just a point I am not sure to understand properly on the stack processor.

According to your configuration, processors will be called in this order:
signal_handler
exception_catcher
ack
max_messages
your processor
max_messages
ack
exception_catcher
signal _handler

This means that for every message consumption, we ack 2 times (before and after our internal processor) ? we catch any ex before and after our internal processor?

I though it is just a "one pass" processor stack
I am a little bit confused right now

from swarrotbundle.

odolbeau avatar odolbeau commented on June 2, 2024

When using a stack, your processor is decorated by others processors.

If you use only the ack processor:

  • your processor is injected in the ack processor constructor
  • the ack processor is called
  • it calls you processor. If there is an error, the message is nacked, otherwise, it's acked.

Take a look a the implementation: https://github.com/swarrot/swarrot/blob/master/src/Swarrot/Processor/Ack/AckProcessor.php#L47-L63

This way, all processors can do some job before and / or after calling the next processor.

Not sure my explanations are really clear. :/ Does it makes sense?

from swarrotbundle.

noniagriconomie avatar noniagriconomie commented on June 2, 2024

@odolbeau thank you again for your time

what i mean is, seeing your comment (cf my previous post)
i understood that the processors stack defined is call before and after our processor

that is why i asked for "clarification" after your comment, because seeing the code and the picture on the readme of the lib (https://camo.githubusercontent.com/8ac89cd415aebfb1026b2278093dbcc986b126da/68747470733a2f2f646f63732e676f6f676c652e636f6d2f64726177696e67732f642f3145615f514a486f2d3970375957386c5f62793753344e494430652d41477058527a7a6974416c59593543632f7075623f773d39363026683d373230) seems weird

Thanks

from swarrotbundle.

stof avatar stof commented on June 2, 2024

This means that for every message consumption, we ack 2 times (before and after our internal processor) ? we catch any ex before and after our internal processor?

no, we don't ack twice. We run the AckProcessor logic in a specific place of the stack. But the AckProcessor is not acking the message both before and after calling the inner processing (actually, the AckProcessor does nothing before calling the inner processing, but it is still reached in the stack)

from swarrotbundle.

noniagriconomie avatar noniagriconomie commented on June 2, 2024

@stof ok understood
Thank you both

from swarrotbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.