I need to sent the acknowledged stanzas after a specific job so I need to disable the automatic way.
Why do you want to make the SM ack dependent on a specific job? Do you try to overload the ack with additional semantic? I really discourage doing so. Instead use e.g. IQ replies or delayed notification messages.
No, i don’t want to add additional semantic. I want to reuse the same standard ack messages.
Suppose I’m offline, all the messages sent to me are stored into offline DB.
When I will be online, I receive the first message and I have to manage it before managing the other. Moreover, when I receive this first message, I automatically send the ack and Openfire delete this message from the DB.
If for some reason my app crashes before managing the first message, when it goes online again, it cannot receive that first message anymore, so it cannot be able to manage the other messages.
Well that shouldn’t happen to often, should it? And only messages stanzas are affected, not IQs. I think the solution to your problem should be using XEP-0313 - Message Archive Management and not deferring the SM ack until the stanza is processed in some special way (which is also possible, but requires some modifications to Smack).
Smack does not really support manual ACK for receive, even when Stream Management is used. All received message will be ACKed by library after receive listener is called.
I found this to be problematic as well as in my application sometimes we cannot ACK the received messages right away, we need to make sure the messages are all completely stored and it can be in the different module/thread from the receive listener.