[
https://issues.apache.org/jira/browse/AMQNET-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15081440#comment-15081440
]
Timothy Bish commented on AMQNET-514:
-------------------------------------
I've tried to reproduce this using code in the NMS.ActiveMQ 1.7.x branch using
this simplified version of your test case and it works fine, maybe you can give
it a go.
{code}
[Test]
public void TestMessageQueueDequeQueueDequeue()
{
using (IConnection connection = CreateConnection())
using (ISession session = connection.CreateSession())
{
IDestination destination =
session.GetQueue("TestMessageQueueDequeQueueDequeue");
(connection as Connection).DeleteDestination(destination);
using (IMessageConsumer consumer =
session.CreateConsumer(destination))
using (IMessageProducer producer =
session.CreateProducer(destination))
{
connection.Start();
producer.DeliveryMode = MsgDeliveryMode.Persistent;
IMapMessage request = session.CreateMapMessage();
request.Body.SetString("Unit-Test-Key", "Unit-Test-Value");
Assert.IsNotNull(request, "request is null");
Assert.IsTrue(request.Body.Contains("Unit-Test-Key"),
"Unit-Test-Key does not exist");
producer.Send(request);
// Relay from Queue back again.
IMessage received =
consumer.Receive(TimeSpan.FromSeconds(2));
Assert.IsNotNull(received);
IMapMessage mapMessage = received as IMapMessage;
Assert.IsNotNull(mapMessage);
producer.Send(mapMessage);
// Read it again and validate.
received = consumer.Receive(TimeSpan.FromSeconds(2));
Assert.IsNotNull(received);
mapMessage = received as IMapMessage;
Assert.IsNotNull(mapMessage, "currentMessage is null");
// This entry in the map message should not be removed
Assert.IsFalse(mapMessage.Body.Contains("Unit-Test-Key"),
"Unit-Test-Key does not exist");
}
}
}
{code}
> Lazy loading of map messages does not work correctly
> ----------------------------------------------------
>
> Key: AMQNET-514
> URL: https://issues.apache.org/jira/browse/AMQNET-514
> Project: ActiveMQ .Net
> Issue Type: Bug
> Components: ActiveMQ, NMS
> Affects Versions: 1.7.0, 1.7.1
> Environment: Apache NMS 1.7.0.3635
> Apache NMS ActiveMQ 1.7.0.3660
> Runtime Version v4.0.30319
> Spring Messaging NMS 2.0.1.40000
> Reporter: Oliver Probst
> Assignee: Jim Gomes
> Priority: Critical
> Labels: test
>
> I use Apache NMS ActiveMQ together with Spring NMS and map messages. I use
> two persistent queues. Dequeuing without accessing the message and then
> queuing the same message again results in a removal of the complete body of
> the map message. The use case is that we move a map message to an error queue
> if an exception occurs while dequeuing. I've got a unit test which shows that
> behaviour (unit test fails but should not) with one persistent queue
> (queue=>dequeue=>queue=>dequeue):
> UNIT TEST (withouth Spring NMS)
> {Code}
> [Test]
> public void QueueDequeQueueDequeueTestWithoutSpringNms()
> {
> // This test should FAIL if the bug is fixed within the Apache NMS
> ActiveMQ framework
> var connecturi = new
> Uri("failover:(tcp://IP:PORT)?initialReconnectDelay=100");
> IConnectionFactory factory = new ConnectionFactory(connecturi);
> using (IConnection connection = factory.CreateConnection())
> using (ISession session = connection.CreateSession())
> {
> IDestination destination = SessionUtil.GetDestination(session,
> "queue://FOO.BAR");
> using (IMessageConsumer consumer =
> session.CreateConsumer(destination))
> using (IMessageProducer producer =
> session.CreateProducer(destination))
> {
> connection.Start();
> producer.DeliveryMode = MsgDeliveryMode.Persistent;
> producer.RequestTimeout = TimeSpan.FromSeconds(5);
> consumer.Listener += DequeueFirstTime;
> var request = session.CreateMapMessage();
> request.Body.SetString("Unit-Test-Key",
> "Unit-Test-Value");
> // Queue
> Assert.IsNotNull(request, "request is null");
> Assert.IsTrue(request.Body.Contains("Unit-Test-Key"),
> "Unit-Test-Key does not exist");
> producer.Send(request);
> }
> }
> }
> private static void DequeueFirstTime(IMessage receivedMsg)
> {
> // Dequeue
> var currentMessage = receivedMsg as IMapMessage;
> Assert.IsNotNull(currentMessage, "currentMessage is null");
> // This test should FAIL if the bug is fixed within the Apache NMS
> ActiveMQ framework
> var connecturi = new
> Uri("failover:(tcp://IP:PORT)?initialReconnectDelay=100");
> IConnectionFactory factory = new ConnectionFactory(connecturi);
> using (IConnection connection = factory.CreateConnection())
> using (ISession session = connection.CreateSession())
> {
> IDestination destination = SessionUtil.GetDestination(session,
> "queue://FOO.BAR");
> using (IMessageConsumer consumer =
> session.CreateConsumer(destination))
> using (IMessageProducer producer =
> session.CreateProducer(destination))
> {
> connection.Start();
> producer.DeliveryMode = MsgDeliveryMode.Persistent;
> producer.RequestTimeout = TimeSpan.FromSeconds(5);
> consumer.Listener += DequeueSecondTime;
> // Queue again
> producer.Send(currentMessage);
> }
> }
> }
> private static void DequeueSecondTime(IMessage receivedMsg)
> {
> // Dequeue again
> var currentMessage = receivedMsg as IMapMessage;
> Assert.IsNotNull(currentMessage, "currentMessage is null");
> // This entry in the map message should not be removed
> Assert.IsFalse(currentMessage.Body.Contains("Unit-Test-Key"),
> "Unit-Test-Key does not exist");
> }
> {Code}
> UNIT TEST (with Spring NMS)
> {Code}
> [Test]
> public void QueueDequeueQueueDequeueTest()
> {
> IConnectionFactory factory = CreateConnectionFactory();
> var nmsTemplate = new NmsTemplate(factory) { ReceiveTimeout = 5000 };
> // Queue
> nmsTemplate.SendWithDelegate("queue://FOO.BAR", delegate(ISession session)
> {
> var mapMessage = session.CreateMapMessage();
> mapMessage.Body.SetString("Unit-Test-Key", "Unit-Test-Value");
> return mapMessage;
> });
> // Dequeue
> var currentMessage = nmsTemplate.Receive("queue://FOO.BAR") as IMapMessage;
> Assert.IsNotNull(currentMessage, "currentMessage is null");
> // Queue
> IMapMessage message = currentMessage;
> nmsTemplate.SendWithDelegate("queue://FOO.BAR", session => message);
> Assert.IsNotNull(currentMessage, "currentMessage is null");
> // Dequeue
> currentMessage = nmsTemplate.Receive("queue://FOO.BAR") as IMapMessage;
> Assert.IsNotNull(currentMessage, "currentMessage is null");
> Assert.IsTrue(currentMessage.Body.Contains("Unit-Test-Key"), "Unit-Test-Key
> does not exist");
> }
> {Code}
> I've checked the implementation. Using text messages everything is fine, but
> within the Apache.NMS.ActiveMQ.Commands.ActiveMQMapMessage class the Body
> property implementation is broken (with high probability ;-))
> Thanks for going on with Apache NMS!
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)