Jerry Jacob's Blog

JBoss Seam – ConcurrentRequestTimeoutException: Concurrent call to conversation

Posted in Java/ J2EE by jerlinworld on February 17, 2012

This problem is commonly seen in applications that use Ajax in the context of a long-running conversation. If the problem happens when a conversation is still active, it’s because one of the requests could not get a lock on the conversation in the allotted time period. Many developers run into this problem for the first time when using a CRUD application created by seam-gen. This entry explains the problem using the seam-gen application as an example.

Given below the reason why I got this exception:
I made 2 ajax calls one after another.


<h:inputText id="zip" value="#{location.instance.zip}">
   <a:support event="onblur" reRender="zipField" bypassUpdates="true" ajaxSingle="true"/>
   <a:support event="onchange" reRender="longitude,latitude" action="#{location.setGeocode()}"/>
</h:inputText>


The issue can be fixed by serializing the requests sent to the server so that they never contend for the conversation. This can be done using the eventsQueue attribute.
‘eventsQueue’ attribute provide a queue in which events are placed. All events are queued and requests are sent to the server serially. This is useful if the request to the server can take some time to execute (e.g. heavy computation, retrieving information from a slow source)


<h:inputText id="zip" value="#{location.instance.zip}">
   <a:support event="onblur" reRender="zipField" bypassUpdates="true" ajaxSingle="true" eventsQueue="default"/>
   <a:support event="onchange" reRender="longitude,latitude" eventsQueue="default" action="#{location.setGeocode()}"/>
</h:inputText>


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: