[
https://issues.apache.org/jira/browse/AMQ-1741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13812141#comment-13812141
]
Claus Ibsen commented on AMQ-1741:
----------------------------------
The JCA has been improved a lot for 5.9 release.
And a lot has improved in many years. Try with latest release to see if you
have any problems still.
> 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/jira/browse/AMQ-1741
> Project: ActiveMQ
> Issue Type: Bug
> Components: Broker
> Affects Versions: 5.0.0, 5.1.0
> Environment: JBoss 4.2.2 on Linux, with RA with tcp transport
> configured
> Reporter: Alexis Kinsella
> Fix For: NEEDS_REVIEWED
>
>
> 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 was sent by Atlassian JIRA
(v6.1#6144)