[ 
https://issues.apache.org/jira/browse/QPID-4088?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alex Rudyy updated QPID-4088:
-----------------------------

    Description: 
Java JMS client does not fully conform JMS spec requirements 4.3.5 about 
closing a connection:

{quote}

4.3.5 Closing a Connection
If one or more of the connection’s session’s message listeners is processing a 
message at the point when connection close is invoked, all the facilities of 
the connection and its sessions must remain available to those listeners until 
they return control to the JMS provider.

{quote}

I assume that the above means that all JMS operations in 
MessageListener#onMessage(Message) should succeed including 
rollback/commit/acknowledge/recover.

With current implementation such operations throws 
javax.jms.IllegalStateException: Object 
org.apache.qpid.client.AMQSession_0_10@54c01e99 has been closed

{noformat}
javax.jms.IllegalStateException: Object 
org.apache.qpid.client.AMQSession_0_10@54c01e99 has been closed
        at org.apache.qpid.client.Closeable.checkNotClosed(Closeable.java:69)
        at org.apache.qpid.client.AMQSession.checkNotClosed(AMQSession.java:578)
        at org.apache.qpid.client.AMQSession.getTransacted(AMQSession.java:1629)
        at 
org.apache.qpid.client.AMQSession.checkTransacted(AMQSession.java:2432)
        at org.apache.qpid.client.AMQSession.commit(AMQSession.java:850)
        at TestClient3$2.onMessage(TestClient3.java:69)
        at 
org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:751)
        at 
org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:141)
        at 
org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:725)
        at 
org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:186)
        at 
org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:1)
        at 
org.apache.qpid.client.AMQSession$Dispatcher.notifyConsumer(AMQSession.java:3475)
        at 
org.apache.qpid.client.AMQSession$Dispatcher.dispatchMessage(AMQSession.java:3414)
        at 
org.apache.qpid.client.AMQSession$Dispatcher.access$1(AMQSession.java:3377)
        at org.apache.qpid.client.AMQSession.dispatch(AMQSession.java:3194)
        at 
org.apache.qpid.client.message.UnprocessedMessage.dispatch(UnprocessedMessage.java:54)
        at 
org.apache.qpid.client.AMQSession$Dispatcher.run(AMQSession.java:3337)
        at java.lang.Thread.run(Thread.java:662)
{noformat} 

The following code reproduces the issue
{noformat} 
        Properties properties = new Properties();
        properties.put("java.naming.factory.initial", 
"org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
        properties.put("connectionfactory.local", 
"amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672'");

        Context context = new InitialContext(properties);
        ConnectionFactory factory = (ConnectionFactory) context.lookup("local");
        Connection connection = factory.createConnection();
        connection.setExceptionListener(new ExceptionListener()
        {

            @Override
            public void onException(JMSException exception)
            {
                System.out.println("Exception listener");
                exception.printStackTrace();
            }
        });
        final Session session = connection.createSession(true, 
Session.SESSION_TRANSACTED);
        Destination destination = session.createQueue("test");
        MessageProducer producer = session.createProducer(destination);
        MessageConsumer consumer = session.createConsumer(destination);

        producer.send(session.createTextMessage("Test"));
        session.commit();

        final CountDownLatch countDownLatch = new CountDownLatch(1);
        consumer.setMessageListener(new MessageListener(){

            @Override
            public void onMessage(Message message)
            {
                countDownLatch.countDown();
                try
                {
                    Thread.sleep(3000l);
                }
                catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
                try
                {
                    session.commit();
                }
                catch (JMSException e)
                {
                    e.printStackTrace();
                }
            }});
        connection.start();
        countDownLatch.await(1, TimeUnit.MINUTES);
        System.out.println("Closing connection before commit");
        connection.close();

{noformat} 



  was:
Java JMS client does not fully conform JMS spec requirements 4.3.5 about 
closing a connection:

{noformat}

4.3.5 Closing a Connection
If one or more of the connection’s session’s message listeners is processing a 
message at the point when connection close is invoked, all the facilities of 
the connection and its sessions must remain available to those listeners until 
they return control to the JMS provider.

{noformat}

I assume that the above means that all JMS operations in 
MessageListener#onMessage(Message) should succeed including 
rollback/commit/acknowledge/recover.

With current implementation such operations throws 
javax.jms.IllegalStateException: Object 
org.apache.qpid.client.AMQSession_0_10@54c01e99 has been closed

{noformat}
javax.jms.IllegalStateException: Object 
org.apache.qpid.client.AMQSession_0_10@54c01e99 has been closed
        at org.apache.qpid.client.Closeable.checkNotClosed(Closeable.java:69)
        at org.apache.qpid.client.AMQSession.checkNotClosed(AMQSession.java:578)
        at org.apache.qpid.client.AMQSession.getTransacted(AMQSession.java:1629)
        at 
org.apache.qpid.client.AMQSession.checkTransacted(AMQSession.java:2432)
        at org.apache.qpid.client.AMQSession.commit(AMQSession.java:850)
        at TestClient3$2.onMessage(TestClient3.java:69)
        at 
org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:751)
        at 
org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:141)
        at 
org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:725)
        at 
org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:186)
        at 
org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:1)
        at 
org.apache.qpid.client.AMQSession$Dispatcher.notifyConsumer(AMQSession.java:3475)
        at 
org.apache.qpid.client.AMQSession$Dispatcher.dispatchMessage(AMQSession.java:3414)
        at 
org.apache.qpid.client.AMQSession$Dispatcher.access$1(AMQSession.java:3377)
        at org.apache.qpid.client.AMQSession.dispatch(AMQSession.java:3194)
        at 
org.apache.qpid.client.message.UnprocessedMessage.dispatch(UnprocessedMessage.java:54)
        at 
org.apache.qpid.client.AMQSession$Dispatcher.run(AMQSession.java:3337)
        at java.lang.Thread.run(Thread.java:662)
{noformat} 

The following code reproduces the issue
{noformat} 
        Properties properties = new Properties();
        properties.put("java.naming.factory.initial", 
"org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
        properties.put("connectionfactory.local", 
"amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672'");

        Context context = new InitialContext(properties);
        ConnectionFactory factory = (ConnectionFactory) context.lookup("local");
        Connection connection = factory.createConnection();
        connection.setExceptionListener(new ExceptionListener()
        {

            @Override
            public void onException(JMSException exception)
            {
                System.out.println("Exception listener");
                exception.printStackTrace();
            }
        });
        final Session session = connection.createSession(true, 
Session.SESSION_TRANSACTED);
        Destination destination = session.createQueue("test");
        MessageProducer producer = session.createProducer(destination);
        MessageConsumer consumer = session.createConsumer(destination);

        producer.send(session.createTextMessage("Test"));
        session.commit();

        final CountDownLatch countDownLatch = new CountDownLatch(1);
        consumer.setMessageListener(new MessageListener(){

            @Override
            public void onMessage(Message message)
            {
                countDownLatch.countDown();
                try
                {
                    Thread.sleep(3000l);
                }
                catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
                try
                {
                    session.commit();
                }
                catch (JMSException e)
                {
                    e.printStackTrace();
                }
            }});
        connection.start();
        countDownLatch.await(1, TimeUnit.MINUTES);
        System.out.println("Closing connection before commit");
        connection.close();

{noformat} 



    
> Java JMS client does not fully conform JMS spec requirements 4.3.5 about 
> closing a connection
> ---------------------------------------------------------------------------------------------
>
>                 Key: QPID-4088
>                 URL: https://issues.apache.org/jira/browse/QPID-4088
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Client
>    Affects Versions: 0.6, 0.8, 0.10, 0.12, 0.14, 0.16, 0.17
>            Reporter: Alex Rudyy
>
> Java JMS client does not fully conform JMS spec requirements 4.3.5 about 
> closing a connection:
> {quote}
> 4.3.5 Closing a Connection
> If one or more of the connection’s session’s message listeners is processing 
> a message at the point when connection close is invoked, all the facilities 
> of the connection and its sessions must remain available to those listeners 
> until they return control to the JMS provider.
> {quote}
> I assume that the above means that all JMS operations in 
> MessageListener#onMessage(Message) should succeed including 
> rollback/commit/acknowledge/recover.
> With current implementation such operations throws 
> javax.jms.IllegalStateException: Object 
> org.apache.qpid.client.AMQSession_0_10@54c01e99 has been closed
> {noformat}
> javax.jms.IllegalStateException: Object 
> org.apache.qpid.client.AMQSession_0_10@54c01e99 has been closed
>       at org.apache.qpid.client.Closeable.checkNotClosed(Closeable.java:69)
>       at org.apache.qpid.client.AMQSession.checkNotClosed(AMQSession.java:578)
>       at org.apache.qpid.client.AMQSession.getTransacted(AMQSession.java:1629)
>       at 
> org.apache.qpid.client.AMQSession.checkTransacted(AMQSession.java:2432)
>       at org.apache.qpid.client.AMQSession.commit(AMQSession.java:850)
>       at TestClient3$2.onMessage(TestClient3.java:69)
>       at 
> org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:751)
>       at 
> org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:141)
>       at 
> org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:725)
>       at 
> org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:186)
>       at 
> org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:1)
>       at 
> org.apache.qpid.client.AMQSession$Dispatcher.notifyConsumer(AMQSession.java:3475)
>       at 
> org.apache.qpid.client.AMQSession$Dispatcher.dispatchMessage(AMQSession.java:3414)
>       at 
> org.apache.qpid.client.AMQSession$Dispatcher.access$1(AMQSession.java:3377)
>       at org.apache.qpid.client.AMQSession.dispatch(AMQSession.java:3194)
>       at 
> org.apache.qpid.client.message.UnprocessedMessage.dispatch(UnprocessedMessage.java:54)
>       at 
> org.apache.qpid.client.AMQSession$Dispatcher.run(AMQSession.java:3337)
>       at java.lang.Thread.run(Thread.java:662)
> {noformat} 
> The following code reproduces the issue
> {noformat} 
>         Properties properties = new Properties();
>         properties.put("java.naming.factory.initial", 
> "org.apache.qpid.jndi.PropertiesFileInitialContextFactory");
>         properties.put("connectionfactory.local", 
> "amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672'");
>         Context context = new InitialContext(properties);
>         ConnectionFactory factory = (ConnectionFactory) 
> context.lookup("local");
>         Connection connection = factory.createConnection();
>         connection.setExceptionListener(new ExceptionListener()
>         {
>             @Override
>             public void onException(JMSException exception)
>             {
>                 System.out.println("Exception listener");
>                 exception.printStackTrace();
>             }
>         });
>         final Session session = connection.createSession(true, 
> Session.SESSION_TRANSACTED);
>         Destination destination = session.createQueue("test");
>         MessageProducer producer = session.createProducer(destination);
>         MessageConsumer consumer = session.createConsumer(destination);
>         producer.send(session.createTextMessage("Test"));
>         session.commit();
>         final CountDownLatch countDownLatch = new CountDownLatch(1);
>         consumer.setMessageListener(new MessageListener(){
>             @Override
>             public void onMessage(Message message)
>             {
>                 countDownLatch.countDown();
>                 try
>                 {
>                     Thread.sleep(3000l);
>                 }
>                 catch (InterruptedException e)
>                 {
>                     e.printStackTrace();
>                 }
>                 try
>                 {
>                     session.commit();
>                 }
>                 catch (JMSException e)
>                 {
>                     e.printStackTrace();
>                 }
>             }});
>         connection.start();
>         countDownLatch.await(1, TimeUnit.MINUTES);
>         System.out.println("Closing connection before commit");
>         connection.close();
> {noformat} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to