[ 
https://issues.apache.org/activemq/browse/AMQNET-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=56101#action_56101
 ] 

Palm Kevin commented on AMQNET-214:
-----------------------------------

Here two test-cases.
The first is working and the second crashes on ??Read first message a second 
time??
Working test:
{noformat} Public Sub IndividualAcknowledgeMultiMessages_AcknowledgeSecondTest()
        Dim messageId As String = Nothing
        Using connection As IConnection = New 
ActiveMQ.ConnectionFactory("tcp:\\localhost:61616").CreateConnection()
            connection.Start()
            Using session As ISession = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge)
                ' Delete queue in order to ensure it is empty
                session.DeleteDestination(session.GetQueue("TestQueue"))

                Dim prod As IMessageProducer = 
session.CreateProducer(session.GetQueue("TestQueue"))
                Dim msg As ITextMessage = prod.CreateTextMessage("test")
                prod.Send(msg, MsgDeliveryMode.Persistent, MsgPriority.Normal, 
TimeSpan.MinValue)
                prod.Close()
                messageId = msg.NMSMessageId
                Assert.IsNotNull(messageId)
                Dim consumer = 
session.CreateConsumer(session.GetQueue("TestQueue"), "JMSMessageID='" + 
messageId + "'")
                Dim fetchedMessage = 
consumer.Receive(TimeSpan.FromMilliseconds(TIMEOUT))
                Assert.IsNotNull(fetchedMessage)
                Assert.AreEqual("test", CType(fetchedMessage, 
ITextMessage).Text)
                consumer.Close()
            End Using
        End Using
    End Sub
{noformat} 
Not working test:
{noformat}Public Sub IndividualAcknowledgeMultiMessages_AcknowledgeFirstTest()
        Using connection As IConnection = New 
ActiveMQ.ConnectionFactory("tcp:\\localhost:61616").CreateConnection()
            connection.Start()
            Using session As ISession = 
connection.CreateSession(AcknowledgementMode.IndividualAcknowledge)
                ' Delete queue in order to ensure it is empty
                session.DeleteDestination(session.GetQueue("TestQueue"))

                ' Push 2 messages to queue
                Dim prod As IMessageProducer = 
session.CreateProducer(session.GetQueue("TestQueue"))
                Dim msg As ITextMessage = prod.CreateTextMessage("test 1")
                prod.Send(msg, MsgDeliveryMode.Persistent, MsgPriority.Normal, 
TimeSpan.MinValue)
                msg = prod.CreateTextMessage("test 2")
                prod.Send(msg, MsgDeliveryMode.Persistent, MsgPriority.Normal, 
TimeSpan.MinValue)
                prod.Close()

                Dim consumer = 
session.CreateConsumer(session.GetQueue("TestQueue"))
                ' Read the first message
                Dim fetchedMessage1 = 
consumer.Receive(TimeSpan.FromMilliseconds(TIMEOUT))
                Assert.IsNotNull(fetchedMessage1)
                Assert.AreEqual("test 1", CType(fetchedMessage1, 
ITextMessage).Text)
                Dim fetchedMessage2 = 
consumer.Receive(TimeSpan.FromMilliseconds(TIMEOUT))
                Assert.IsNotNull(fetchedMessage2)
                Assert.AreEqual("test 2", CType(fetchedMessage2, 
ITextMessage).Text)

                ' Acknowledge first message
                fetchedMessage1.Acknowledge()

                consumer.Close()

                ' Read first message a second time
                consumer = session.CreateConsumer(session.GetQueue("TestQueue"))
                fetchedMessage1 = 
consumer.Receive(TimeSpan.FromMilliseconds(TIMEOUT))
                Assert.IsNotNull(fetchedMessage1)
                Assert.AreEqual("test 2", CType(fetchedMessage1, 
ITextMessage).Text)

                ' Try to read second message a second time
                fetchedMessage2 = 
consumer.Receive(TimeSpan.FromMilliseconds(TIMEOUT))
                Assert.IsNull(fetchedMessage2)
                consumer.Close()
            End Using
        End Using
    End Sub
{noformat} 

> Individual Acknowledge only working on last message in queue
> ------------------------------------------------------------
>
>                 Key: AMQNET-214
>                 URL: https://issues.apache.org/activemq/browse/AMQNET-214
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>          Components: ActiveMQ
>    Affects Versions: 1.2.0
>            Reporter: Palm Kevin
>            Assignee: Jim Gomes
>            Priority: Critical
>
> The new acknowldege-mode _IndividualAcknowledge_ seems not working correctly.
> The _message.Acknowledge()_ does only work if called on last message of the 
> queue!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to