You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Oliver Probst (JIRA)" <ji...@apache.org> on 2016/01/04 10:32:39 UTC
[jira] [Updated] (AMQNET-514) Lazy loading of map messages does not
work correctly
[ https://issues.apache.org/jira/browse/AMQNET-514?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oliver Probst updated AMQNET-514:
---------------------------------
Description:
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)
[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://172.17.172.36:61621)?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://172.17.172.36:61621)?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");
}
[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");
}
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!
was:
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):
[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");
}
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!
> 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)
> [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://172.17.172.36:61621)?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://172.17.172.36:61621)?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");
> }
> [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");
> }
> 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)