powered by Jive Software

Need for multi-thread plugin coding?

hi,

I’'m trying to develop a plugin /component, got one question here:

if I got heavy traffic to and from this plugin, do I need to code it using threads, so that it handles packets efficiently? for example, use multiple threads to handle different packets.

or, rather, the wifi server itself also has a mechanism to cope with this situation?

please help

Hi newjabber,

Without knowing exactly what you’'re trying to do it makes it a bit difficult to make recommendations. Generally speaking however, I would avoid using threads unless you determine you need to use them. In the case of writing plugins for Wildfire, you can benchmark Wildfire with and without your plugin installed; if you see a drop in performance then you know that there is a bottleneck in your plugin. Then, when you determine where the bottleneck is in your plugin you can investigate if using multiple threads would be helpful.

By chance are you working with a PacketInterceptor? If so, the javadocs on the IterceptorManager#invokeInterceptors() method has the following recommendation, “If possible, interceptors should perform their work in a short time so that overall performance is not compromised.”

Hope that helps,

Ryan

hi ryang,

thanks for your reply.

I’‘m thinking of a component, that forwards messages to and from 2 different groups, without letting members in each group aware of specific user’'s JID in another group, or even nickname in group:

member A in group X send message to group Y (to component JID), there will be member B in group Y answers, then A-B communicates by sending messages to the component JID, without disturbing other members at all. the plugin component will take care of matching A-B relations.

so is PacketInterceptor a better choice?

Hi newjabber,

For what you’‘re trying to do I would probably avoid using a PacketInterceptor and start off by looking at the url=http://www.jivesoftware.org/plugins.jspbroadcast plugin[/url] url=http://www.jivesoftware.org/source.jspsource[/url]. But, in either case, you shouldn’'t have to worry about using threads.

Hope that helps,

Ryan

thank you ryang.

then component it is and no threads.