Project

General

Profile

Component Development Question

Geoffrey Hamamoto
Added about 4 years ago

Hello, I am creating a new component. I am wondering if it is guaranteed that a single instance of the component class will be instantiated. What are the ramifications of setting processingOutThreads and processingInThreads? The reason this is important is because this component will create a tcp/ip connection to another application and I want to be sure that only a single connection is created.

Thanks.


Replies (3)

Added by Wojciech Kapcia TigaseTeam about 4 years ago

Geoffrey Hamamoto wrote:

Hello, I am creating a new component.

I'm assuming you have read Component Implementation - Lesson 3 - Multi-Threading ?

I am wondering if it is guaranteed that a single instance of the component class will be instantiated.

You can have multiple instances of your component if you configure Tigase that way:

--comp-name-1 = conference
--comp-class-1 = tigase.muc.MUCComponent
--comp-name-2 = muc
--comp-class-2 = tigase.muc.MUCComponent

Above will create two instances of tigase.muc.MUCComponent component available under two different names (keep in mind that this is not very popular configuration, however it's possible)

What are the ramifications of setting processingOutThreads and processingInThreads? The reason this is important is because this component will create a tcp/ip connection to another application and I want to be sure that only a single connection is created.

As the guide reads - those are only responsible for number of threads that will invoke processPacket(…) method. You can create logic that would establish connection when needed and then share between all threads.

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 4 years ago

I would like to add something to Wojciech comments.

I am wondering if it is guaranteed that a single instance of the component class will be instantiated.

It is not. In fact the server was designed to allow for multiple instances of the same component to run at the same time. As Wojciech pointed out, however, each component has a different ID and separate configuration.

What are the ramifications of setting processingOutThreads and processingInThreads?

These are number of threads for your component instance processing XMPP packets outgoing from your component instance and incoming to your component instance.

The reason this is important is because this component will create a tcp/ip connection to another application and I want to be sure that only a single connection is created.

You can control this through the component configuration. Moreover, consider basing your component logic on the ConnectionManager component in Tigase, so you can reuse all the configuration and networking logic already implemented.

Added by Geoffrey Hamamoto about 4 years ago

Thanks Artur and Wojciech. Your answers are much appreciated.

    (1-3/3)