activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Isaac Liao (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (AMQ-3829) browse message may break message order
Date Tue, 08 May 2012 01:51:48 GMT

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

Isaac Liao closed AMQ-3829.
---------------------------

       Resolution: Fixed
    Fix Version/s: 5.6.0
    
> browse message may break message order
> --------------------------------------
>
>                 Key: AMQ-3829
>                 URL: https://issues.apache.org/jira/browse/AMQ-3829
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.5.1
>         Environment: Windows 7, ActiveMQ-5.5.1
>            Reporter: Isaac Liao
>             Fix For: 5.6.0
>
>
> Test steps:
> 1. send 3 messages: 1, 2, 3
> 2. browse message, call: MessageBrowser#nextElement
> 3. consume message. expect message 1, but fail
> public class ActiveMQProblemTest {
>     private Queue queue = new ActiveMQQueue("test");
>     private String url = "tcp://127.0.0.1:61616";
>     private String username = "";
>     private String password = "";
>     
>     @Test
>     public void test() {
>         produce();
>         browse();
>         consume();
>     }
>     
>     private void browse() {
>         Connection conn = null;
>         Session session = null;
>         try {
>             conn = newConnection();
>             session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
>             QueueBrowser b = session.createBrowser(queue);
>             b.getEnumeration().nextElement();
>         } catch (Throwable ex) {
>             ex.printStackTrace();
>             Assert.fail(ex.getMessage());
>         } finally {
>             JMSHelper.closeQuietly(conn);
>         }
>     }
>     
>     public void produce() {
>         Connection conn = null;
>         Session session = null;
>         try {
>             conn = newConnection();
>             session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
>             produce(session, queue, "1");
>             produce(session, queue, "2");
>             produce(session, queue, "3");
>         } catch (Throwable ex) {
>             ex.printStackTrace();
>             Assert.fail(ex.getMessage());
>         } finally {
>             JMSHelper.closeQuietly(conn);
>         }
>     }
>     private void produce(Session session, Queue queue, String txt) throws JMSException
{
>         MessageProducer p = session.createProducer(queue);
>         p.send(session.createTextMessage(txt));
>         p.close();
>     }
>     
>     public void consume() {
>         Connection conn = null;
>         Session session = null;
>         try {
>             conn = newConnection();
>             session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
>             Assert.assertEquals("1", receive(queue, session));
>             Assert.assertEquals("2", receive(queue, session));
>             Assert.assertEquals("3", receive(queue, session));
>         } catch (Throwable ex) {
>             ex.printStackTrace();
>             Assert.fail(ex.getMessage());
>         } finally {
>             JMSHelper.closeQuietly(conn);
>         }
>     }
>     
>     private String receive(Queue queue, Session session) throws JMSException {
>         MessageConsumer consumer = session.createConsumer(queue);
>         TextMessage msg = (TextMessage) consumer.receive(1000);
>         String result = msg.getText();
>         consumer.close();
>         return result;
>     }
>     private Connection newConnection() throws JMSException {
>         Connection conn = new ActiveMQConnectionFactory(username, password, url).createConnection();
>         conn.start();
>         return conn;
>     }
> }

--
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

        

Mime
View raw message