Project

General

Profile

Reprocessing messages stored thanks to AMP when Tigase is restarted

Luca Stucchi
Added almost 4 years ago

Hi there,

I have a component that, when gets a message that is going to be stored via AMP, creates a timer and keeps it in memory for the component to use in a second time .

If, for any reason, Tigase is restarted, the timer, which is stored in memory is obviously lost.

I am looking for a way to make Tigase reprocess stored message so that I can have my component to recreate the timers and resume the business logic.

My question is:

  • is there a way to instruct tigase to automatically reprocess stored messages upon server restart ? (I couldn't find it but I would be glad to discover that I am wrong)

  • if there is no way to have message automatically reprocessed, in your opinion what could the best way to implement this behavior be ?

Thanks in advance,

Luca


Replies (4)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 4 years ago

There is no ready to use framework or config option for such a thing. However, AMP component does a similar thing. It stores messages in database but as some of the messages do have special, time sensitive processing conditions, AMP reads from database messages which need to be processed in near future, so it keeps them in memory for fast access and sets a timer for a message which should be processed first. This is for optimizations and to reduce DB access as much as possible.

I think you could employ similar approach.

Added by Luca Stucchi almost 4 years ago

Well, mutatis mutandis, I think too I could employ a similar approach.

I am going to dive into AMP implementation and look for the code doing that.

Once found it, I think I'll put the code handling the "reload from DB and reprocess" into the component initializationCompleted() implementation, to be sure that everything is ready to react to events that will be triggered by the reload. Does it seem a good idea to you guys ?

All the best,

Luca

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 4 years ago

I hope I am not misguiding you now (it has been a while since I worked on the code), but I think you should take a look at tigase.server.amp package and classes: MsgRepository and JDBCMsgRepository and track usage of the expiredQueue collection.

Added by Luca Stucchi almost 4 years ago

Hi Artur,

don't worry the solution is up and running since the day after I asked you: at last I took some concepts from JDBCMsgRepository and implemented a component that only performs an initialization task, accessing the database and reprocessing what I needed to reprocess.

Thanks again,

Luca

    (1-4/4)