You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by snowch <sn...@coralms.com> on 2009/05/14 16:30:59 UTC

EntityListIterator and open connections

Hi Forum,

In the GenericDelegator findListIteratorByCondition() methods, there is the
following warning regarding the EntityListIterator:

NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE  DONE WITH IT, AND DON'T LEAVE IT
OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.

If I have a user paging through a data list form, how can I know when they
have finished so that the EntityListIterator can be closed?

Many thanks in advance,

Chris
-- 
View this message in context: http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23541834.html
Sent from the OFBiz - User mailing list archive at Nabble.com.


Re: EntityListIterator and open connections

Posted by snowch <sn...@coralms.com>.
Aha!  I think I was previously just seeing the connections getting reused in
the connection pool...


snowch wrote:
> 
> I have been providing my list in the form actions element (see below).  It
> would appear from sql server activity monitor that the connections for the
> form is being kept open.  Do I need to move my script to the screen action
> element to ensure that the connections are closed?
> 
> Many thanks,
> 
> Chris
> 
>    <form name="MyHistoryReportList" 
>     	type="list" 
>     	list-name="myHistoryList"
>     	view-size="20"    	
>     	paginate="true"
>         paginate-target="MyHistoryReport"
>          >
>         <actions>
>         	<script
> location="component://xxx/script/uk/co/xxx/FindActionHistory.bsh"/>
>         </actions>
> 
> 
> 
> David E Jones-3 wrote:
>> 
>> 
>> Yes.
>> 
>> -David
>> 
>> 
>> On May 14, 2009, at 7:18 PM, snowch wrote:
>> 
>>>
>>> If I am using an ofbiz form to display a paginated list, does the  
>>> form take
>>> care of closing the EntityListIterator at the end of each request?
>>>
>>>
>>> David E Jones-3 wrote:
>>>>
>>>>
>>>> In a webapp you simply can't leave the connection open, you have to
>>>> close it at the end of each page request.
>>>>
>>>> Feel free to try leaving it open between requests and then put the
>>>> server under a load... what always happens (yep, always, no silver
>>>> lining scenarios here...) is that the connection pool and related
>>>> resources are consumed quickly and while the hardware is under almost
>>>> no load the server starts rejecting requests or things simply time  
>>>> out.
>>>>
>>>> It's fairly basic stuff actually, but unfortunately transaction
>>>> management is a powerful tool with a lot of powerful bad side-effects
>>>> if you don't use it right. It may seem crazy but it is frighteningly
>>>> common that developers write bad tx mgmt code and  it brings down
>>>> production servers, sometimes causing a project to be cancelled
>>>> because clients loose confidence in the system...
>>>>
>>>> In a desktop application you can keep connections opened longer, but
>>>> it is still risky and usually a lot of monitoring code is required to
>>>> clean things up in possible failure states. In a webapp the  
>>>> monitoring
>>>> and cleanup code has to address lots of tough scenarios and usually
>>>> conflicts with things that are made to allow apps to scale well...  
>>>> and
>>>> those conflicts make it impossible no matter how good a programmer  
>>>> you
>>>> are... you have to choose between scalability and saving on re-query
>>>> time, and in the real world scalability is usually far more important
>>>> and will actually result in lower response times overall.
>>>>
>>>> -David
>>>>
>>>>
>>>> On May 14, 2009, at 8:30 AM, snowch wrote:
>>>>
>>>>>
>>>>> Hi Forum,
>>>>>
>>>>> In the GenericDelegator findListIteratorByCondition() methods, there
>>>>> is the
>>>>> following warning regarding the EntityListIterator:
>>>>>
>>>>> NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE  DONE WITH IT, AND DON'T
>>>>> LEAVE IT
>>>>> OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
>>>>>
>>>>> If I have a user paging through a data list form, how can I know
>>>>> when they
>>>>> have finished so that the EntityListIterator can be closed?
>>>>>
>>>>> Many thanks in advance,
>>>>>
>>>>> Chris
>>>>> -- 
>>>>> View this message in context:
>>>>> http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23541834.html
>>>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>>>>
>>>>
>>>>
>>>>
>>>
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23551852.html
>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>>
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23552526.html
Sent from the OFBiz - User mailing list archive at Nabble.com.


Re: EntityListIterator and open connections

Posted by snowch <sn...@coralms.com>.
I have been providing my list in the form actions element (see below).  It
would appear from sql server activity monitor that the connections for the
form is being kept open.  Do I need to move my script to the screen action
element to ensure that the connections are closed?

Many thanks,

Chris

   <form name="MyHistoryReportList" 
    	type="list" 
    	list-name="myHistoryList"
    	view-size="20"    	
    	paginate="true"
        paginate-target="MyHistoryReport"
         >
        <actions>
        	<script
location="component://xxx/script/uk/co/xxx/FindActionHistory.bsh"/>
        </actions>



David E Jones-3 wrote:
> 
> 
> Yes.
> 
> -David
> 
> 
> On May 14, 2009, at 7:18 PM, snowch wrote:
> 
>>
>> If I am using an ofbiz form to display a paginated list, does the  
>> form take
>> care of closing the EntityListIterator at the end of each request?
>>
>>
>> David E Jones-3 wrote:
>>>
>>>
>>> In a webapp you simply can't leave the connection open, you have to
>>> close it at the end of each page request.
>>>
>>> Feel free to try leaving it open between requests and then put the
>>> server under a load... what always happens (yep, always, no silver
>>> lining scenarios here...) is that the connection pool and related
>>> resources are consumed quickly and while the hardware is under almost
>>> no load the server starts rejecting requests or things simply time  
>>> out.
>>>
>>> It's fairly basic stuff actually, but unfortunately transaction
>>> management is a powerful tool with a lot of powerful bad side-effects
>>> if you don't use it right. It may seem crazy but it is frighteningly
>>> common that developers write bad tx mgmt code and  it brings down
>>> production servers, sometimes causing a project to be cancelled
>>> because clients loose confidence in the system...
>>>
>>> In a desktop application you can keep connections opened longer, but
>>> it is still risky and usually a lot of monitoring code is required to
>>> clean things up in possible failure states. In a webapp the  
>>> monitoring
>>> and cleanup code has to address lots of tough scenarios and usually
>>> conflicts with things that are made to allow apps to scale well...  
>>> and
>>> those conflicts make it impossible no matter how good a programmer  
>>> you
>>> are... you have to choose between scalability and saving on re-query
>>> time, and in the real world scalability is usually far more important
>>> and will actually result in lower response times overall.
>>>
>>> -David
>>>
>>>
>>> On May 14, 2009, at 8:30 AM, snowch wrote:
>>>
>>>>
>>>> Hi Forum,
>>>>
>>>> In the GenericDelegator findListIteratorByCondition() methods, there
>>>> is the
>>>> following warning regarding the EntityListIterator:
>>>>
>>>> NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE  DONE WITH IT, AND DON'T
>>>> LEAVE IT
>>>> OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
>>>>
>>>> If I have a user paging through a data list form, how can I know
>>>> when they
>>>> have finished so that the EntityListIterator can be closed?
>>>>
>>>> Many thanks in advance,
>>>>
>>>> Chris
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23541834.html
>>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>>>
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23551852.html
>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23552282.html
Sent from the OFBiz - User mailing list archive at Nabble.com.


Re: EntityListIterator and open connections

Posted by David E Jones <da...@hotwaxmedia.com>.
Yes.

-David


On May 14, 2009, at 7:18 PM, snowch wrote:

>
> If I am using an ofbiz form to display a paginated list, does the  
> form take
> care of closing the EntityListIterator at the end of each request?
>
>
> David E Jones-3 wrote:
>>
>>
>> In a webapp you simply can't leave the connection open, you have to
>> close it at the end of each page request.
>>
>> Feel free to try leaving it open between requests and then put the
>> server under a load... what always happens (yep, always, no silver
>> lining scenarios here...) is that the connection pool and related
>> resources are consumed quickly and while the hardware is under almost
>> no load the server starts rejecting requests or things simply time  
>> out.
>>
>> It's fairly basic stuff actually, but unfortunately transaction
>> management is a powerful tool with a lot of powerful bad side-effects
>> if you don't use it right. It may seem crazy but it is frighteningly
>> common that developers write bad tx mgmt code and  it brings down
>> production servers, sometimes causing a project to be cancelled
>> because clients loose confidence in the system...
>>
>> In a desktop application you can keep connections opened longer, but
>> it is still risky and usually a lot of monitoring code is required to
>> clean things up in possible failure states. In a webapp the  
>> monitoring
>> and cleanup code has to address lots of tough scenarios and usually
>> conflicts with things that are made to allow apps to scale well...  
>> and
>> those conflicts make it impossible no matter how good a programmer  
>> you
>> are... you have to choose between scalability and saving on re-query
>> time, and in the real world scalability is usually far more important
>> and will actually result in lower response times overall.
>>
>> -David
>>
>>
>> On May 14, 2009, at 8:30 AM, snowch wrote:
>>
>>>
>>> Hi Forum,
>>>
>>> In the GenericDelegator findListIteratorByCondition() methods, there
>>> is the
>>> following warning regarding the EntityListIterator:
>>>
>>> NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE  DONE WITH IT, AND DON'T
>>> LEAVE IT
>>> OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
>>>
>>> If I have a user paging through a data list form, how can I know
>>> when they
>>> have finished so that the EntityListIterator can be closed?
>>>
>>> Many thanks in advance,
>>>
>>> Chris
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23541834.html
>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23551852.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>


Re: EntityListIterator and open connections

Posted by snowch <sn...@coralms.com>.
If I am using an ofbiz form to display a paginated list, does the form take
care of closing the EntityListIterator at the end of each request?


David E Jones-3 wrote:
> 
> 
> In a webapp you simply can't leave the connection open, you have to  
> close it at the end of each page request.
> 
> Feel free to try leaving it open between requests and then put the  
> server under a load... what always happens (yep, always, no silver  
> lining scenarios here...) is that the connection pool and related  
> resources are consumed quickly and while the hardware is under almost  
> no load the server starts rejecting requests or things simply time out.
> 
> It's fairly basic stuff actually, but unfortunately transaction  
> management is a powerful tool with a lot of powerful bad side-effects  
> if you don't use it right. It may seem crazy but it is frighteningly  
> common that developers write bad tx mgmt code and  it brings down  
> production servers, sometimes causing a project to be cancelled  
> because clients loose confidence in the system...
> 
> In a desktop application you can keep connections opened longer, but  
> it is still risky and usually a lot of monitoring code is required to  
> clean things up in possible failure states. In a webapp the monitoring  
> and cleanup code has to address lots of tough scenarios and usually  
> conflicts with things that are made to allow apps to scale well... and  
> those conflicts make it impossible no matter how good a programmer you  
> are... you have to choose between scalability and saving on re-query  
> time, and in the real world scalability is usually far more important  
> and will actually result in lower response times overall.
> 
> -David
> 
> 
> On May 14, 2009, at 8:30 AM, snowch wrote:
> 
>>
>> Hi Forum,
>>
>> In the GenericDelegator findListIteratorByCondition() methods, there  
>> is the
>> following warning regarding the EntityListIterator:
>>
>> NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE  DONE WITH IT, AND DON'T  
>> LEAVE IT
>> OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
>>
>> If I have a user paging through a data list form, how can I know  
>> when they
>> have finished so that the EntityListIterator can be closed?
>>
>> Many thanks in advance,
>>
>> Chris
>> -- 
>> View this message in context:
>> http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23541834.html
>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23551852.html
Sent from the OFBiz - User mailing list archive at Nabble.com.


Re: EntityListIterator and open connections

Posted by David E Jones <da...@hotwaxmedia.com>.
In a webapp you simply can't leave the connection open, you have to  
close it at the end of each page request.

Feel free to try leaving it open between requests and then put the  
server under a load... what always happens (yep, always, no silver  
lining scenarios here...) is that the connection pool and related  
resources are consumed quickly and while the hardware is under almost  
no load the server starts rejecting requests or things simply time out.

It's fairly basic stuff actually, but unfortunately transaction  
management is a powerful tool with a lot of powerful bad side-effects  
if you don't use it right. It may seem crazy but it is frighteningly  
common that developers write bad tx mgmt code and  it brings down  
production servers, sometimes causing a project to be cancelled  
because clients loose confidence in the system...

In a desktop application you can keep connections opened longer, but  
it is still risky and usually a lot of monitoring code is required to  
clean things up in possible failure states. In a webapp the monitoring  
and cleanup code has to address lots of tough scenarios and usually  
conflicts with things that are made to allow apps to scale well... and  
those conflicts make it impossible no matter how good a programmer you  
are... you have to choose between scalability and saving on re-query  
time, and in the real world scalability is usually far more important  
and will actually result in lower response times overall.

-David


On May 14, 2009, at 8:30 AM, snowch wrote:

>
> Hi Forum,
>
> In the GenericDelegator findListIteratorByCondition() methods, there  
> is the
> following warning regarding the EntityListIterator:
>
> NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE  DONE WITH IT, AND DON'T  
> LEAVE IT
> OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
>
> If I have a user paging through a data list form, how can I know  
> when they
> have finished so that the EntityListIterator can be closed?
>
> Many thanks in advance,
>
> Chris
> -- 
> View this message in context: http://www.nabble.com/EntityListIterator-and-open-connections-tp23541834p23541834.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>