You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Alexis Kinsella (JIRA)" <ji...@apache.org> on 2008/05/22 08:56:54 UTC
[jira] Created: (AMQ-1741) Problem related to SessionPooled related
with Web Console deployed in J2EE Container (JBoss) with a resource adapter
and webconsole-jndi.xml
Problem related to SessionPooled related with Web Console deployed in J2EE Container (JBoss) with a resource adapter and webconsole-jndi.xml
--------------------------------------------------------------------------------------------------------------------------------------------
Key: AMQ-1741
URL: https://issues.apache.org/activemq/browse/AMQ-1741
Project: ActiveMQ
Issue Type: Bug
Components: Broker
Affects Versions: 5.1.0, 5.0.0
Environment: JBoss 4.2.2 on Linux, with RA with tcp transport configured
Reporter: Alexis Kinsella
When Web Console is deployed in container with a resource adapter configured there is a bug with SessionPool Class:
When you browse a first queue, the QueueBrowserQuery works, but when you browse a queue a second time, an exception is thrown saying Session is closed (Because managed by Resource Adapter).
One workAround is to create a NullSessionPool that do not pool and that implements a ISessionPool interface! (To change a minimum the WebConsole):
The implements is based on SessionPool class implementation. It may be surely enhanced !
package org.apache.activemq.web;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Session;
public class NullSessionPool implements ISessionPool {
private ConnectionFactory connectionFactory;
private Connection connection;
public Connection getConnection() throws JMSException {
if (checkConnection()) {
return connection;
}
synchronized (this) {
connection = getConnectionFactory().createConnection();
connection.start();
return connection;
}
}
private boolean checkConnection() {
if (connection == null) {
return false;
}
try {
connection.getMetaData();
return true;
} catch (JMSException e) {
return false;
}
}
public void setConnection(Connection connection) {
this.connection = connection;
}
public ConnectionFactory getConnectionFactory() {
if (connectionFactory == null) {
throw new IllegalStateException("No ConnectionFactory has been set for the session pool");
}
return connectionFactory;
}
public void setConnectionFactory(ConnectionFactory connectionFactory) {
this.connectionFactory = connectionFactory;
}
public Session borrowSession() throws JMSException {
return createSession();
}
public void returnSession(Session session) throws JMSException {
session.close();
connection.close();
}
protected Session createSession() throws JMSException {
return getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
}
}
ISessionPool.java:
package org.apache.activemq.web;
import javax.jms.JMSException;
import javax.jms.Session;
public interface ISessionPool {
public abstract Session borrowSession() throws JMSException;
public abstract void returnSession(Session session) throws JMSException;
}
The Spring config becomes:
<bean id="sessionPool" class="org.apache.activemq.web.NullSessionPool">
<property name="connectionFactory" ref="connectionFactory"/>
</bean>
It works great, no more bug with this workaround in a container with a resource adapter that manage connections and sessions.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.