Component development

nurnabi siddique
Added about 5 years ago

Dear Artur/Kopit,

          i am developing a component for tigase server.when i receive a packet  in my component,i check various condition and sometimes doing few database operation too that means sometimes the operation taking large time so is it better to do long lived operation in a component? what you suggest or is it better to do the operation in a separate thread when i receive a packet in my component by using linkedblockingqueue?

Replies (3)


Added by Artur Hefczyc TigaseTeam about 5 years ago

The component can run on multiple threads and you do not need to worry about threads management. This is a built-in feature in the Tigase API: Component Multi-threading

Of course if you have very long operation involving expensive DB calls increasing number of threads can help in a limited way. I suggest to calculate how much time it may take to do some actions, what kind of slowdown you can expect if you have 100 concurrent calls of that type. How frequently this may happen on your system. This if you can support 10k online users, if you can support 100k online users, 1 million online users, etc.... Maybe you do not need to support that many uses but if you do, you need to optimize.

Added by nurnabi siddique about 5 years ago

i am doing very limited db operation but it will be frequently. When a user login to tigase system, i send a presence available stanza to my component. so that when the user logout my component receive presence unavailable message from unavailable message i can ensure user logout time. I am doing a db operation where i insert login,logout and few other information to collect session time of a user. user may login multiple times, i am collecting all logging event of a user.

is it feasible or logical to send presence available stanza to a component?


Added by Artur Hefczyc TigaseTeam about 5 years ago

Yes, what you do is correct and sensible. If this is just user login/logout even then it is not very frequent. There is a feature in Tigase already that you can set user's presence forwarding to an XMPP address and you can send your component address as the destination for presence forwarding.

There is, however, another way to do what you do. Maybe much simpler. You can define own SQL queries for user login and logout events. These queries can be stored procedures and within stored procedures you can do some extra DB operations, record user login time, logout time, and any other information you need.