Uploaded image for project: 'ActiveMQ'
  1. ActiveMQ
  2. AMQ-3829

browse message may break message order

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5.1
    • Fix Version/s: 5.6.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Windows 7, ActiveMQ-5.5.1

      Description

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

      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              shooeugenesea.tw Isaac Liao

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment