Re: [Dev] [Carbon] Carbon Managed Thread Pool Implementation

2015-06-16 Thread Rasika Perera
[adding kasunG, Sameera, Kishanthan]

@RuwanA,

+1 for the clarification. Finally decided to temporarily continue with my
own Thread. However; Without any resource limitation creating Thread for
each subscriber disconnect scenario is not a good practice IMO.

@All

For the initial question; It would be a great If let the community know Is
there any Carbon Thread Pool implemented in Carbon platform?

Thank you

On Thu, Jun 11, 2015 at 8:38 AM, Ruwan Abeykoon ruw...@wso2.com wrote:

 Hi Rasika,
 I think your requirement is to attempt reconnection when some external
 connectivity is lost.

 In this case I think it is better to handle this with your own thread,
 which is quite similar to the code you have posted initially. The thread
 can be created and kept in your connector level (say connection recovery
 thread). You can make it null once reconnection completed and release any
 resources, so that the thread can be GC ed properly.

 I think managing dedicated thread is better as it needs to be done at a
 very low level.
 Thread pool is more suited to handle
 1. common, extensible, pluggable, business workers
 2. I/O read and write

 but it is not good to use thread pool to handle connection management
 logic, because of timing and pool starvation. Also it will give you less
 coupling, good modularity and testability.

 WDYT?

 Cheers,


 On Wed, Jun 10, 2015 at 6:06 PM, Rasika Perera rasi...@wso2.com wrote:

 Hi All,

 Thanks for the prompt replies. You both have pointed NTask carbo-common
 component[1]. Had offline discussions with Nirmal and Anjana on how to
 integrate NTask to a product. I went through the following implementation
 sample [2]. AFAIU NTask is a scheduler implementation which needs some
 extra configurations for the bundle activator as well.

 But I think I need a simpler solution. Is there any way that I can access
 a Carbon Thread Pool simply?

 [1]
 https://github.com/wso2/carbon-commons/tree/master/components/ntask/org.wso2.carbon.ntask.core/src/main/java/org/wso2/carbon/ntask/core

 [2]
 https://github.com/wso2/carbon-analytics/tree/c554c7c988cd5e38ef85308bd3b14068cc33d634/components/analytics-core/org.wso2.carbon.analytics.dataservice/src/main/java/org/wso2/carbon/analytics/dataservice/tasks

 On Wed, Jun 10, 2015 at 12:06 PM, Nirmal Fernando nir...@wso2.com
 wrote:

 Yes, use Carbon ntask feature.

 Sample;

 https://github.com/wso2/carbon-commons/blob/master/components/ntask/org.wso2.carbon.ntask.solutions/src/main/java/org/wso2/carbon/ntask/solutions/webservice/WebServiceCallTask.java

 On Wed, Jun 10, 2015 at 12:00 PM, Ruwan Abeykoon ruw...@wso2.com
 wrote:

 Hi Rasika,
  How about [1] ?

 [1] https://docs.wso2.com/display/Governance460/Scheduled+Task+Sample

 Cheers,


 On Wed, Jun 10, 2015 at 11:08 AM, Rasika Perera rasi...@wso2.com
 wrote:

 Hi Folks,

 I have requirement that needs continuous polling for specific
 subscriber implementation.

 Thread subscriberDaemon = new Thread() {
 public void run() {
 while (true) {
 if (fooLogic) {
 //logic goes here...
 } else {
 return;
 }

 try {
 Thread.sleep(500);
 } catch (InterruptedException e) {
 log.error(An Interrupted Exception in Subscriber
 thread.);
 }
 }
 }
 };


 Since above created Thread is a low level implementation and may
 subjected to the unmanageable resources; Is there any higher level Worker
 Thread model implemented in Carbon platform? Or How can I barrow tomcat
 thread pool through the Carbon APIs?

 Thank you

 --
 With Regards,

 *Rasika Perera*
 Software Engineer
 M: +94 71 680 9060 E: rasi...@wso2.com
 LinkedIn: http://lk.linkedin.com/in/rasika90

 WSO2 Inc. www.wso2.com
 lean.enterprise.middleware

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --

 *Ruwan Abeykoon*
 *Architect,*
 *WSO2, Inc. http://wso2.com http://wso2.com/ *
 *lean.enterprise.middleware.*

 email: ruw...@wso2.com
 phone:(+94) 39736

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --

 Thanks  regards,
 Nirmal

 Associate Technical Lead - Data Technologies Team, WSO2 Inc.
 Mobile: +94715779733
 Blog: http://nirmalfdo.blogspot.com/





 --
 With Regards,

 *Rasika Perera*
 Software Engineer
 M: +94 71 680 9060 E: rasi...@wso2.com
 LinkedIn: http://lk.linkedin.com/in/rasika90

 WSO2 Inc. www.wso2.com
 lean.enterprise.middleware




 --

 *Ruwan Abeykoon*
 *Architect,*
 *WSO2, Inc. http://wso2.com http://wso2.com/ *
 *lean.enterprise.middleware.*

 email: ruw...@wso2.com
 phone:(+94) 39736




-- 
With Regards,

*Rasika Perera*
Software Engineer
M: +94 71 680 9060 E: rasi...@wso2.com
LinkedIn: http://lk.linkedin.com/in/rasika90

WSO2 Inc. www.wso2.com
lean.enterprise.middleware

Re: [Dev] [Carbon] Carbon Managed Thread Pool Implementation

2015-06-10 Thread Rasika Perera
Hi All,

Thanks for the prompt replies. You both have pointed NTask carbo-common
component[1]. Had offline discussions with Nirmal and Anjana on how to
integrate NTask to a product. I went through the following implementation
sample [2]. AFAIU NTask is a scheduler implementation which needs some
extra configurations for the bundle activator as well.

But I think I need a simpler solution. Is there any way that I can access a
Carbon Thread Pool simply?

[1]
https://github.com/wso2/carbon-commons/tree/master/components/ntask/org.wso2.carbon.ntask.core/src/main/java/org/wso2/carbon/ntask/core

[2]
https://github.com/wso2/carbon-analytics/tree/c554c7c988cd5e38ef85308bd3b14068cc33d634/components/analytics-core/org.wso2.carbon.analytics.dataservice/src/main/java/org/wso2/carbon/analytics/dataservice/tasks

On Wed, Jun 10, 2015 at 12:06 PM, Nirmal Fernando nir...@wso2.com wrote:

 Yes, use Carbon ntask feature.

 Sample;

 https://github.com/wso2/carbon-commons/blob/master/components/ntask/org.wso2.carbon.ntask.solutions/src/main/java/org/wso2/carbon/ntask/solutions/webservice/WebServiceCallTask.java

 On Wed, Jun 10, 2015 at 12:00 PM, Ruwan Abeykoon ruw...@wso2.com wrote:

 Hi Rasika,
  How about [1] ?

 [1] https://docs.wso2.com/display/Governance460/Scheduled+Task+Sample

 Cheers,


 On Wed, Jun 10, 2015 at 11:08 AM, Rasika Perera rasi...@wso2.com wrote:

 Hi Folks,

 I have requirement that needs continuous polling for specific subscriber
 implementation.

 Thread subscriberDaemon = new Thread() {
 public void run() {
 while (true) {
 if (fooLogic) {
 //logic goes here...
 } else {
 return;
 }

 try {
 Thread.sleep(500);
 } catch (InterruptedException e) {
 log.error(An Interrupted Exception in Subscriber
 thread.);
 }
 }
 }
 };


 Since above created Thread is a low level implementation and may
 subjected to the unmanageable resources; Is there any higher level Worker
 Thread model implemented in Carbon platform? Or How can I barrow tomcat
 thread pool through the Carbon APIs?

 Thank you

 --
 With Regards,

 *Rasika Perera*
 Software Engineer
 M: +94 71 680 9060 E: rasi...@wso2.com
 LinkedIn: http://lk.linkedin.com/in/rasika90

 WSO2 Inc. www.wso2.com
 lean.enterprise.middleware

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --

 *Ruwan Abeykoon*
 *Architect,*
 *WSO2, Inc. http://wso2.com http://wso2.com/ *
 *lean.enterprise.middleware.*

 email: ruw...@wso2.com
 phone:(+94) 39736

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --

 Thanks  regards,
 Nirmal

 Associate Technical Lead - Data Technologies Team, WSO2 Inc.
 Mobile: +94715779733
 Blog: http://nirmalfdo.blogspot.com/





-- 
With Regards,

*Rasika Perera*
Software Engineer
M: +94 71 680 9060 E: rasi...@wso2.com
LinkedIn: http://lk.linkedin.com/in/rasika90

WSO2 Inc. www.wso2.com
lean.enterprise.middleware
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Carbon] Carbon Managed Thread Pool Implementation

2015-06-10 Thread Ruwan Abeykoon
Hi Rasika,
 How about [1] ?

[1] https://docs.wso2.com/display/Governance460/Scheduled+Task+Sample

Cheers,


On Wed, Jun 10, 2015 at 11:08 AM, Rasika Perera rasi...@wso2.com wrote:

 Hi Folks,

 I have requirement that needs continuous polling for specific subscriber
 implementation.

 Thread subscriberDaemon = new Thread() {
 public void run() {
 while (true) {
 if (fooLogic) {
 //logic goes here...
 } else {
 return;
 }

 try {
 Thread.sleep(500);
 } catch (InterruptedException e) {
 log.error(An Interrupted Exception in Subscriber
 thread.);
 }
 }
 }
 };


 Since above created Thread is a low level implementation and may subjected
 to the unmanageable resources; Is there any higher level Worker Thread
 model implemented in Carbon platform? Or How can I barrow tomcat thread
 pool through the Carbon APIs?

 Thank you

 --
 With Regards,

 *Rasika Perera*
 Software Engineer
 M: +94 71 680 9060 E: rasi...@wso2.com
 LinkedIn: http://lk.linkedin.com/in/rasika90

 WSO2 Inc. www.wso2.com
 lean.enterprise.middleware

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 

*Ruwan Abeykoon*
*Architect,*
*WSO2, Inc. http://wso2.com http://wso2.com/ *
*lean.enterprise.middleware.*

email: ruw...@wso2.com
phone:(+94) 39736
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Carbon] Carbon Managed Thread Pool Implementation

2015-06-10 Thread Nirmal Fernando
Yes, use Carbon ntask feature.

Sample;
https://github.com/wso2/carbon-commons/blob/master/components/ntask/org.wso2.carbon.ntask.solutions/src/main/java/org/wso2/carbon/ntask/solutions/webservice/WebServiceCallTask.java

On Wed, Jun 10, 2015 at 12:00 PM, Ruwan Abeykoon ruw...@wso2.com wrote:

 Hi Rasika,
  How about [1] ?

 [1] https://docs.wso2.com/display/Governance460/Scheduled+Task+Sample

 Cheers,


 On Wed, Jun 10, 2015 at 11:08 AM, Rasika Perera rasi...@wso2.com wrote:

 Hi Folks,

 I have requirement that needs continuous polling for specific subscriber
 implementation.

 Thread subscriberDaemon = new Thread() {
 public void run() {
 while (true) {
 if (fooLogic) {
 //logic goes here...
 } else {
 return;
 }

 try {
 Thread.sleep(500);
 } catch (InterruptedException e) {
 log.error(An Interrupted Exception in Subscriber
 thread.);
 }
 }
 }
 };


 Since above created Thread is a low level implementation and may
 subjected to the unmanageable resources; Is there any higher level Worker
 Thread model implemented in Carbon platform? Or How can I barrow tomcat
 thread pool through the Carbon APIs?

 Thank you

 --
 With Regards,

 *Rasika Perera*
 Software Engineer
 M: +94 71 680 9060 E: rasi...@wso2.com
 LinkedIn: http://lk.linkedin.com/in/rasika90

 WSO2 Inc. www.wso2.com
 lean.enterprise.middleware

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --

 *Ruwan Abeykoon*
 *Architect,*
 *WSO2, Inc. http://wso2.com http://wso2.com/ *
 *lean.enterprise.middleware.*

 email: ruw...@wso2.com
 phone:(+94) 39736

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 

Thanks  regards,
Nirmal

Associate Technical Lead - Data Technologies Team, WSO2 Inc.
Mobile: +94715779733
Blog: http://nirmalfdo.blogspot.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [Carbon] Carbon Managed Thread Pool Implementation

2015-06-10 Thread Ruwan Abeykoon
Hi Rasika,
I think your requirement is to attempt reconnection when some external
connectivity is lost.

In this case I think it is better to handle this with your own thread,
which is quite similar to the code you have posted initially. The thread
can be created and kept in your connector level (say connection recovery
thread). You can make it null once reconnection completed and release any
resources, so that the thread can be GC ed properly.

I think managing dedicated thread is better as it needs to be done at a
very low level.
Thread pool is more suited to handle
1. common, extensible, pluggable, business workers
2. I/O read and write

but it is not good to use thread pool to handle connection management
logic, because of timing and pool starvation. Also it will give you less
coupling, good modularity and testability.

WDYT?

Cheers,


On Wed, Jun 10, 2015 at 6:06 PM, Rasika Perera rasi...@wso2.com wrote:

 Hi All,

 Thanks for the prompt replies. You both have pointed NTask carbo-common
 component[1]. Had offline discussions with Nirmal and Anjana on how to
 integrate NTask to a product. I went through the following implementation
 sample [2]. AFAIU NTask is a scheduler implementation which needs some
 extra configurations for the bundle activator as well.

 But I think I need a simpler solution. Is there any way that I can access
 a Carbon Thread Pool simply?

 [1]
 https://github.com/wso2/carbon-commons/tree/master/components/ntask/org.wso2.carbon.ntask.core/src/main/java/org/wso2/carbon/ntask/core

 [2]
 https://github.com/wso2/carbon-analytics/tree/c554c7c988cd5e38ef85308bd3b14068cc33d634/components/analytics-core/org.wso2.carbon.analytics.dataservice/src/main/java/org/wso2/carbon/analytics/dataservice/tasks

 On Wed, Jun 10, 2015 at 12:06 PM, Nirmal Fernando nir...@wso2.com wrote:

 Yes, use Carbon ntask feature.

 Sample;

 https://github.com/wso2/carbon-commons/blob/master/components/ntask/org.wso2.carbon.ntask.solutions/src/main/java/org/wso2/carbon/ntask/solutions/webservice/WebServiceCallTask.java

 On Wed, Jun 10, 2015 at 12:00 PM, Ruwan Abeykoon ruw...@wso2.com wrote:

 Hi Rasika,
  How about [1] ?

 [1] https://docs.wso2.com/display/Governance460/Scheduled+Task+Sample

 Cheers,


 On Wed, Jun 10, 2015 at 11:08 AM, Rasika Perera rasi...@wso2.com
 wrote:

 Hi Folks,

 I have requirement that needs continuous polling for specific
 subscriber implementation.

 Thread subscriberDaemon = new Thread() {
 public void run() {
 while (true) {
 if (fooLogic) {
 //logic goes here...
 } else {
 return;
 }

 try {
 Thread.sleep(500);
 } catch (InterruptedException e) {
 log.error(An Interrupted Exception in Subscriber
 thread.);
 }
 }
 }
 };


 Since above created Thread is a low level implementation and may
 subjected to the unmanageable resources; Is there any higher level Worker
 Thread model implemented in Carbon platform? Or How can I barrow tomcat
 thread pool through the Carbon APIs?

 Thank you

 --
 With Regards,

 *Rasika Perera*
 Software Engineer
 M: +94 71 680 9060 E: rasi...@wso2.com
 LinkedIn: http://lk.linkedin.com/in/rasika90

 WSO2 Inc. www.wso2.com
 lean.enterprise.middleware

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --

 *Ruwan Abeykoon*
 *Architect,*
 *WSO2, Inc. http://wso2.com http://wso2.com/ *
 *lean.enterprise.middleware.*

 email: ruw...@wso2.com
 phone:(+94) 39736

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --

 Thanks  regards,
 Nirmal

 Associate Technical Lead - Data Technologies Team, WSO2 Inc.
 Mobile: +94715779733
 Blog: http://nirmalfdo.blogspot.com/





 --
 With Regards,

 *Rasika Perera*
 Software Engineer
 M: +94 71 680 9060 E: rasi...@wso2.com
 LinkedIn: http://lk.linkedin.com/in/rasika90

 WSO2 Inc. www.wso2.com
 lean.enterprise.middleware




-- 

*Ruwan Abeykoon*
*Architect,*
*WSO2, Inc. http://wso2.com http://wso2.com/ *
*lean.enterprise.middleware.*

email: ruw...@wso2.com
phone:(+94) 39736
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] [Carbon] Carbon Managed Thread Pool Implementation

2015-06-09 Thread Rasika Perera
Hi Folks,

I have requirement that needs continuous polling for specific subscriber
implementation.

Thread subscriberDaemon = new Thread() {
public void run() {
while (true) {
if (fooLogic) {
//logic goes here...
} else {
return;
}

try {
Thread.sleep(500);
} catch (InterruptedException e) {
log.error(An Interrupted Exception in Subscriber thread.);
}
}
}
};


Since above created Thread is a low level implementation and may subjected
to the unmanageable resources; Is there any higher level Worker Thread
model implemented in Carbon platform? Or How can I barrow tomcat thread
pool through the Carbon APIs?

Thank you

-- 
With Regards,

*Rasika Perera*
Software Engineer
M: +94 71 680 9060 E: rasi...@wso2.com
LinkedIn: http://lk.linkedin.com/in/rasika90

WSO2 Inc. www.wso2.com
lean.enterprise.middleware
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev