[jboss-cvs] JBoss Messaging SVN: r7802 - in branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617: src/main/org/jboss/jms/message and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Sep 13 00:37:53 EDT 2009
Author: jbertram at redhat.com
Date: 2009-09-13 00:37:53 -0400 (Sun, 13 Sep 2009)
New Revision: 7802
Modified:
branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/docs/userguide/en/modules/introduction.xml
branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/src/main/org/jboss/jms/message/JBossMessage.java
branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/src/main/org/jboss/messaging/core/impl/message/MessageSupport.java
branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java
branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java
Log:
[JBPAPP-2347]
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/docs/userguide/en/modules/introduction.xml
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/docs/userguide/en/modules/introduction.xml 2009-09-11 15:20:00 UTC (rev 7801)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/docs/userguide/en/modules/introduction.xml 2009-09-13 04:37:53 UTC (rev 7802)
@@ -199,4 +199,17 @@
identical, so they will require some simple adjustments to get them to work with JBoss Messaging. Also, the database data model is completely different, so don't attempt to use JBoss Messaging with a JBoss MQ data schema and vice-versa.
</important></para>
</section>
+
+ <section id="properties">
+ <title>System Properties used by JBoss Messaging</title>
+
+ <section id="properties.supportBytesId">
+ <title>support.bytesId</title>
+
+ <para>This system property controls the default behavior when constructing a JBossMessage object from a foreign message object. If set to true, the JBossMessage constructor
+ will try to extract the native byte[] correlation ID from the foreign message headers. If set to false, it will use the normal string type JMSCorrelationID. If this system property is absent or
+ is given some value other than 'true' and 'false', it will defaults to 'true'.</para>
+ </section>
+ </section>
+
</chapter>
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/src/main/org/jboss/jms/message/JBossMessage.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/src/main/org/jboss/jms/message/JBossMessage.java 2009-09-11 15:20:00 UTC (rev 7801)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/src/main/org/jboss/jms/message/JBossMessage.java 2009-09-13 04:37:53 UTC (rev 7802)
@@ -338,15 +338,27 @@
super(messageID);
setJMSTimestamp(foreign.getJMSTimestamp());
-
- try
+
+ if (supportBytesId)
{
- byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes();
- setJMSCorrelationIDAsBytes(corrIDBytes);
+ try
+ {
+ byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes();
+ setJMSCorrelationIDAsBytes(corrIDBytes);
+ }
+ catch(JMSException e)
+ {
+ // specified as String
+ String corrIDString = foreign.getJMSCorrelationID();
+ if (corrIDString != null)
+ {
+ setJMSCorrelationID(corrIDString);
+ }
+ }
}
- catch(JMSException e)
+ else
{
- // specified as String
+ //https://jira.jboss.org/jira/browse/JBMESSAGING-1617
String corrIDString = foreign.getJMSCorrelationID();
if (corrIDString != null)
{
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/src/main/org/jboss/messaging/core/impl/message/MessageSupport.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/src/main/org/jboss/messaging/core/impl/message/MessageSupport.java 2009-09-11 15:20:00 UTC (rev 7801)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/src/main/org/jboss/messaging/core/impl/message/MessageSupport.java 2009-09-13 04:37:53 UTC (rev 7802)
@@ -54,6 +54,14 @@
// Constants -----------------------------------------------------
private static final Logger log = Logger.getLogger(MessageSupport.class);
+
+ protected static boolean supportBytesId;
+
+ static
+ {
+ String value = System.getProperty("support.bytesId");
+ supportBytesId = !"false".equals(value);
+ }
// Attributes ----------------------------------------------------
@@ -289,6 +297,11 @@
{
this.persisted = persisted;
}
+
+ public static void setSupportBytesId(boolean b)
+ {
+ supportBytesId = b;
+ }
// Public --------------------------------------------------------
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java 2009-09-11 15:20:00 UTC (rev 7801)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java 2009-09-13 04:37:53 UTC (rev 7802)
@@ -863,6 +863,43 @@
ensureEquivalent(foreignMessage, copy);
}
+ public void testCopyForeignCorrelationID() throws JMSException
+ {
+ Message foreignMessage = new SimpleJMSMessage();
+ foreignMessage.setJMSCorrelationID("ID:test-string-id");
+
+ JBossMessage copy = new JBossMessage(foreignMessage, 0);
+
+ assertEquals(foreignMessage.getJMSCorrelationID(), copy.getJMSCorrelationID());
+ }
+
+ //https://jira.jboss.org/jira/browse/JBMESSAGING-1617
+ public void testCopyForeignCorrelationIDNoBytesID() throws JMSException
+ {
+ Message foreignMessage = new SimpleJMSMessage(false);
+ foreignMessage.setJMSCorrelationID("ID:test-string-id");
+
+ JBossMessage copy = null;
+ try
+ {
+ copy = new JBossMessage(foreignMessage, 0);
+ fail("Should throw UnsupportedOperationException");
+ }
+ catch (UnsupportedOperationException e)
+ {
+ //ignore
+ }
+
+ JBossMessage.setSupportBytesId(false);
+ foreignMessage = new SimpleJMSMessage(false);
+ foreignMessage.setJMSCorrelationID("ID:test-string-id");
+
+ copy = new JBossMessage(foreignMessage, 0);
+
+ assertEquals(foreignMessage.getJMSCorrelationID(), copy.getJMSCorrelationID());
+ JBossMessage.setSupportBytesId(true);
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java 2009-09-11 15:20:00 UTC (rev 7801)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP08.patch01_JBMESSAGING_1617/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java 2009-09-13 04:37:53 UTC (rev 7802)
@@ -69,7 +69,11 @@
this.ignoreSetDestination = true;
this.destination = dest;
}
-
+
+ public SimpleJMSMessage(boolean allowBytesId)
+ {
+ this.supportBytesId = allowBytesId;
+ }
// Message implementation ----------------------------------------
@@ -106,10 +110,15 @@
private byte[] correlationIDBytes;
private String correlationIDString;
private boolean isCorrelationIDBytes;
+ private boolean supportBytesId = true;
public byte[] getJMSCorrelationIDAsBytes() throws JMSException
{
+ if (!supportBytesId)
+ {
+ throw new UnsupportedOperationException("Don't support bytes ID");
+ }
if (!isCorrelationIDBytes)
{
throw new JMSException("CorrelationID is a String for this message");
@@ -119,6 +128,10 @@
public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException
{
+ if (!supportBytesId)
+ {
+ throw new UnsupportedOperationException("Don't support bytes ID");
+ }
if (correlationID == null || correlationID.length == 0)
{
throw new JMSException("Please specify a non-zero length byte[]");
More information about the jboss-cvs-commits
mailing list