Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

A few commits for EAP #1734

Merged
merged 2 commits into from

2 participants

@jbertram
Owner

FYI - these have already been done on 2.4.x and master.

jbertram added some commits
@jbertram jbertram HORNETQ-1370 - Setting String property to null on a Message breaks XM…
…LExporter tool

Conflicts:
	hornetq-tools/src/main/java/org/hornetq/tools/XmlDataImporter.java
	tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/XmlImportExportTest.java
31b299d
@jbertram jbertram HORNETQ-1367 - Allow QueueControlImpl.removeMessage(long) to operate …
…on scheduled messages
ea2091e
@clebertsuconic clebertsuconic merged commit 28c2c26 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 22, 2014
  1. @jbertram

    HORNETQ-1370 - Setting String property to null on a Message breaks XM…

    jbertram authored
    …LExporter tool
    
    Conflicts:
    	hornetq-tools/src/main/java/org/hornetq/tools/XmlDataImporter.java
    	tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/XmlImportExportTest.java
  2. @jbertram
This page is out of date. Refresh to see the latest.
View
6 hornetq-server/src/main/java/org/hornetq/core/server/impl/QueueImpl.java
@@ -1342,6 +1342,12 @@ public synchronized boolean deleteReference(final long messageID) throws Excepti
}
}
+ if (!deleted)
+ {
+ // Look in scheduled deliveries
+ deleted = scheduledDeliveryHandler.removeReferenceWithID(messageID) != null ? true : false;
+ }
+
tx.commit();
return deleted;
View
2  hornetq-tools/src/main/java/org/hornetq/tools/XmlDataConstants.java
@@ -117,4 +117,6 @@ private XmlDataConstants()
static final String JMS_JNDI_ENTRY = "entry";
public static final String JNDI_COMPATIBILITY_PREFIX = "java:jboss/exported/";
+
+ static final String NULL = "_HQ_NULL";
}
View
2  hornetq-tools/src/main/java/org/hornetq/tools/XmlDataExporter.java
@@ -950,7 +950,7 @@ private void printMessageProperties(ServerMessage message) throws XMLStreamExcep
}
else
{
- xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_VALUE, value.toString());
+ xmlWriter.writeAttribute(XmlDataConstants.PROPERTY_VALUE, value == null ? XmlDataConstants.NULL : value.toString());
}
if (value instanceof Boolean)
View
13 hornetq-tools/src/main/java/org/hornetq/tools/XmlDataImporter.java
@@ -414,6 +414,7 @@ private void processMessageProperties(Message message)
String key = "";
String value = "";
String propertyType = "";
+ String realValue = null;
for (int i = 0; i < reader.getAttributeCount(); i++)
{
@@ -466,11 +467,19 @@ else if (propertyType.equals(XmlDataConstants.PROPERTY_TYPE_LONG))
}
else if (propertyType.equals(XmlDataConstants.PROPERTY_TYPE_SIMPLE_STRING))
{
- message.putStringProperty(new SimpleString(key), new SimpleString(value));
+ if (!value.equals(XmlDataConstants.NULL))
+ {
+ realValue = value;
+ }
+ message.putStringProperty(new SimpleString(key), new SimpleString(realValue));
}
else if (propertyType.equals(XmlDataConstants.PROPERTY_TYPE_STRING))
{
- message.putStringProperty(key, value);
+ if (!value.equals(XmlDataConstants.NULL))
+ {
+ realValue = value;
+ }
+ message.putStringProperty(key, realValue);
}
}
View
43 tests/integration-tests/src/test/java/org/hornetq/tests/integration/management/QueueControlTest.java
@@ -35,6 +35,7 @@
import org.hornetq.api.core.management.MessageCounterInfo;
import org.hornetq.api.core.management.QueueControl;
import org.hornetq.core.config.Configuration;
+import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.messagecounter.impl.MessageCounterManagerImpl;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
@@ -1078,6 +1079,48 @@ public void testRemoveMessage() throws Exception
}
@Test
+ public void testRemoveScheduledMessage() throws Exception
+ {
+ SimpleString address = RandomUtil.randomSimpleString();
+ SimpleString queue = RandomUtil.randomSimpleString();
+
+ session.createQueue(address, queue, null, false);
+ ClientProducer producer = session.createProducer(address);
+
+ // send 2 messages on queue, both scheduled
+ long timeout = System.currentTimeMillis() + 5000;
+ ClientMessage m1 = session.createMessage(true);
+ m1.putLongProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME, timeout);
+ producer.send(m1);
+ ClientMessage m2 = session.createMessage(true);
+ m2.putLongProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME, timeout);
+ producer.send(m2);
+
+ QueueControl queueControl = createManagementControl(address, queue);
+ Assert.assertEquals(2, queueControl.getScheduledCount());
+
+ // the message IDs are set on the server
+ Map<String, Object>[] messages = queueControl.listScheduledMessages();
+ Assert.assertEquals(2, messages.length);
+ long messageID = (Long) messages[0].get("messageID");
+
+ // delete 1st message
+ boolean deleted = queueControl.removeMessage(messageID);
+ Assert.assertTrue(deleted);
+ Assert.assertEquals(1, queueControl.getScheduledCount());
+
+ // check there is a single message to consume from queue
+ while (timeout > System.currentTimeMillis() && queueControl.getScheduledCount() == 1)
+ {
+ Thread.sleep(100);
+ }
+
+ ManagementTestBase.consumeMessages(1, session, queue);
+
+ session.deleteQueue(queue);
+ }
+
+ @Test
public void testRemoveMessage2() throws Exception
{
SimpleString address = RandomUtil.randomSimpleString();
View
8 tests/integration-tests/src/test/java/org/hornetq/tests/integration/persistence/XmlImportExportTest.java
@@ -96,10 +96,14 @@ public void testMessageProperties() throws Exception
msg.putIntProperty("myIntProperty", i);
msg.putLongProperty("myLongProperty", Long.MAX_VALUE - i);
msg.putObjectProperty("myObjectProperty", i);
+ msg.putObjectProperty("myNullObjectProperty", null);
msg.putShortProperty("myShortProperty", new Integer(i).shortValue());
msg.putStringProperty("myStringProperty", "myStringPropertyValue_" + i);
+ msg.putStringProperty("myNullStringProperty", null);
msg.putStringProperty("myNonAsciiStringProperty", international.toString());
msg.putStringProperty("mySpecialCharacters", special);
+ msg.putStringProperty(new SimpleString("mySimpleStringProperty"), new SimpleString("mySimpleStringPropertyValue_" + i));
+ msg.putStringProperty(new SimpleString("myNullSimpleStringProperty"), null);
producer.send(msg);
}
@@ -142,10 +146,14 @@ public void testMessageProperties() throws Exception
Assert.assertEquals(i, msg.getIntProperty("myIntProperty").intValue());
Assert.assertEquals(Long.MAX_VALUE - i, msg.getLongProperty("myLongProperty").longValue());
Assert.assertEquals(i, msg.getObjectProperty("myObjectProperty"));
+ Assert.assertEquals(null, msg.getObjectProperty("myNullObjectProperty"));
Assert.assertEquals(new Integer(i).shortValue(), msg.getShortProperty("myShortProperty").shortValue());
Assert.assertEquals("myStringPropertyValue_" + i, msg.getStringProperty("myStringProperty"));
+ Assert.assertEquals(null, msg.getStringProperty("myNullStringProperty"));
Assert.assertEquals(international.toString(), msg.getStringProperty("myNonAsciiStringProperty"));
Assert.assertEquals(special, msg.getStringProperty("mySpecialCharacters"));
+ Assert.assertEquals(new SimpleString("mySimpleStringPropertyValue_" + i), msg.getSimpleStringProperty(new SimpleString("mySimpleStringProperty")));
+ Assert.assertEquals(null, msg.getSimpleStringProperty(new SimpleString("myNullSimpleStringProperty")));
}
}
Something went wrong with that request. Please try again.