From do-not-reply at jboss.org Mon Jan 23 07:00:47 2012
Content-Type: multipart/mixed; boundary="===============3762795101094471390=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: hornetq-commits at lists.jboss.org
Subject: [hornetq-commits] JBoss hornetq SVN: r12043 -
trunk/hornetq-jms/src/main/java/org/hornetq/jms/bridge/impl.
Date: Mon, 23 Jan 2012 07:00:47 -0500
Message-ID: <201201231200.q0NC0lLJ031315@svn01.web.mwc.hst.phx2.redhat.com>
--===============3762795101094471390==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: borges
Date: 2012-01-23 07:00:46 -0500 (Mon, 23 Jan 2012)
New Revision: 12043
Modified:
trunk/hornetq-jms/src/main/java/org/hornetq/jms/bridge/impl/JMSBridgeImp=
l.java
Log:
Fix synchronization inconsistency, and remove warnings.
Modified: trunk/hornetq-jms/src/main/java/org/hornetq/jms/bridge/impl/JMSBr=
idgeImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/hornetq-jms/src/main/java/org/hornetq/jms/bridge/impl/JMSBridgeIm=
pl.java 2012-01-23 12:00:29 UTC (rev 12042)
+++ trunk/hornetq-jms/src/main/java/org/hornetq/jms/bridge/impl/JMSBridgeIm=
pl.java 2012-01-23 12:00:46 UTC (rev 12043)
@@ -21,6 +21,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -58,7 +59,7 @@
import org.hornetq.jms.client.HornetQSession;
=
/**
- * =
+ *
* A JMSBridge
*
* @author Tim Fox
@@ -565,7 +566,7 @@
targetDestinationFactory =3D dest;
}
=
- public String getSourceUsername()
+ public synchronized String getSourceUsername()
{
return sourceUsername;
}
@@ -801,7 +802,7 @@
=
/**
* Check the object is not null
- * =
+ *
* @throws IllegalArgumentException if the object is null
*/
private static void checkNotNull(final Object obj, final String name)
@@ -814,7 +815,7 @@
=
/**
* Check the bridge is not started
- * =
+ *
* @throws IllegalStateException if the bridge is started
*/
private void checkBridgeNotStarted()
@@ -827,7 +828,7 @@
=
/**
* Check that value is either equals to -1 or greater than 0
- * =
+ *
* @throws IllegalArgumentException if the value is not valid
*/
private static void checkValidValue(final long value, final String name)
@@ -1024,32 +1025,32 @@
* If the source and target destinations are on the same server (same r=
esource manager) then,
* in order to get ONCE_AND_ONLY_ONCE, we simply need to consuming and =
send in a single
* local JMS transaction.
- * =
+ *
* We actually use a single local transacted session for the other QoS =
modes too since this
* is more performant than using DUPS_OK_ACKNOWLEDGE or AUTO_ACKNOWLEDG=
E session ack modes, so effectively
* the QoS is upgraded.
- * =
+ *
* Source and target on different server
* -------------------------------------
* If the source and target destinations are on a different servers (di=
fferent resource managers) then:
- * =
+ *
* If desired QoS is ONCE_AND_ONLY_ONCE, then we start a JTA transactio=
n and enlist the consuming and sending
* XAResources in that.
- * =
+ *
* If desired QoS is DUPLICATES_OK then, we use CLIENT_ACKNOWLEDGE for =
the consuming session and
* AUTO_ACKNOWLEDGE (this is ignored) for the sending session if the ma=
xBatchSize =3D=3D 1, otherwise we
* use a local transacted session for the sending session where maxBatc=
hSize > 1, since this is more performant
* When bridging a batch, we make sure to manually acknowledge the cons=
uming session, if it is CLIENT_ACKNOWLEDGE
* *after* the batch has been sent
- * =
+ *
* If desired QoS is AT_MOST_ONCE then, if maxBatchSize =3D=3D 1, we us=
e AUTO_ACKNOWLEDGE for the consuming session,
* and AUTO_ACKNOWLEDGE for the sending session.
* If maxBatchSize > 1, we use CLIENT_ACKNOWLEDGE for the consuming ses=
sion and a local transacted session for the
* sending session.
- * =
+ *
* When bridging a batch, we make sure to manually acknowledge the cons=
uming session, if it is CLIENT_ACKNOWLEDGE
* *before* the batch has been sent
- * =
+ *
*/
private boolean setupJMSObjects()
{
@@ -1406,7 +1407,7 @@
JMSBridgeImpl.log.trace("Client acking source session");
}
=
- ((Message)messages.getLast()).acknowledge();
+ messages.getLast().acknowledge();
=
if (JMSBridgeImpl.trace)
{
@@ -1532,13 +1533,13 @@
=
private void sendMessages() throws Exception
{
- Iterator iter =3D messages.iterator();
+ Iterator iter =3D messages.iterator();
=
Message msg =3D null;
=
while (iter.hasNext())
{
- msg =3D (Message)iter.next();
+ msg =3D iter.next();
=
if (addMessageIDInHeader)
{
@@ -1636,13 +1637,14 @@
*/
private static void copyProperties(final Message msg) throws JMSExcepti=
on
{
- Enumeration en =3D msg.getPropertyNames();
+ @SuppressWarnings("unchecked")
+ Enumeration en =3D msg.getPropertyNames();
=
Map oldProps =3D null;
=
while (en.hasMoreElements())
{
- String propName =3D (String)en.nextElement();
+ String propName =3D en.nextElement();
=
if (oldProps =3D=3D null)
{
@@ -1656,13 +1658,13 @@
=
if (oldProps !=3D null)
{
- Iterator oldPropsIter =3D oldProps.entrySet().iterator();
+ Iterator> oldPropsIter =3D oldProps.entrySe=
t().iterator();
=
while (oldPropsIter.hasNext())
{
- Map.Entry entry =3D (Map.Entry)oldPropsIter.next();
+ Entry entry =3D oldPropsIter.next();
=
- String propName =3D (String)entry.getKey();
+ String propName =3D entry.getKey();
=
Object val =3D entry.getValue();
=
@@ -1680,7 +1682,7 @@
}
=
/**
- * Creates a 3-sized thred pool executor (1 thread for the sourceReceiv=
er, 1 for the timeChecker
+ * Creates a 3-sized thread pool executor (1 thread for the sourceRecei=
ver, 1 for the timeChecker
* and 1 for the eventual failureHandler)
*/
private ExecutorService createExecutor()
@@ -1730,7 +1732,7 @@
try
{
msg =3D sourceConsumer.receive(1000);
- =
+
if (msg instanceof HornetQMessage)
{
// We need to check the buffer mainly in the case of =
LargeMessages
@@ -1876,12 +1878,14 @@
=
private class StartupFailureHandler extends FailureHandler
{
+ @Override
protected void failed()
{
// Don't call super
JMSBridgeImpl.log.warn("Unable to set up connections, bridge will=
not be started");
}
=
+ @Override
protected void succeeded()
{
// Don't call super - a bit ugly in this case but better than tak=
ing the lock twice.
--===============3762795101094471390==--