Author: rgodfrey
Date: Wed Apr 16 03:17:58 2008
New Revision: 648658

URL: http://svn.apache.org/viewvc?rev=648658&view=rev
Log:
QPID-929 : Exchange.Declare being sent prior to every message when publishing 
to explicit destination

Modified:
    
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
    
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
    
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java

Modified: 
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java?rev=648658&r1=648657&r2=648658&view=diff
==============================================================================
--- 
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
 (original)
+++ 
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
 Wed Apr 16 03:17:58 2008
@@ -53,7 +53,9 @@
     private String _url;
     private AMQShortString _urlAsShortString;
 
-    private boolean _validated;
+    private boolean _checkedForQueueBinding;
+
+    private boolean _exchangeExistsChecked;
 
     private byte[] _byteEncoding;
     private static final int IS_DURABLE_MASK = 0x1;
@@ -202,14 +204,25 @@
 
     }
 
-    public boolean isValidated()
+    public boolean isCheckedForQueueBinding()
+    {
+        return _checkedForQueueBinding;
+    }
+
+    public void setCheckedForQueueBinding(boolean checkedForQueueBinding)
+    {
+        _checkedForQueueBinding = checkedForQueueBinding;
+    }
+
+
+    public boolean isExchangeExistsChecked()
     {
-        return _validated;
+        return _exchangeExistsChecked;
     }
 
-    public void setValidated(boolean validated)
+    public void setExchangeExistsChecked(final boolean exchangeExistsChecked)
     {
-        _validated = validated;
+        _exchangeExistsChecked = exchangeExistsChecked;
     }
 
     public String toURL()

Modified: 
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java?rev=648658&r1=648657&r2=648658&view=diff
==============================================================================
--- 
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
 (original)
+++ 
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
 Wed Apr 16 03:17:58 2008
@@ -140,6 +140,7 @@
 
     private void declareDestination(AMQDestination destination)
     {
+
         ExchangeDeclareBody body = 
getSession().getMethodRegistry().createExchangeDeclareBody(_session.getTicket(),
                                                                                
               destination.getExchangeName(),
                                                                                
               destination.getExchangeClass(),
@@ -410,7 +411,12 @@
                                    + ((destination != null) ? 
destination.getClass() : null));
         }
 
-        declareDestination((AMQDestination) destination);
+        AMQDestination amqDestination = (AMQDestination) destination;
+        if(!amqDestination.isExchangeExistsChecked())
+        {
+            declareDestination(amqDestination);
+            amqDestination.setExchangeExistsChecked(true);
+        }
     }
 
     protected void sendImpl(AMQDestination destination, Message message, int 
deliveryMode, int priority, long timeToLive,

Modified: 
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java?rev=648658&r1=648657&r2=648658&view=diff
==============================================================================
--- 
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java
 (original)
+++ 
incubator/qpid/branches/M2.1/java/client/src/main/java/org/apache/qpid/client/QueueSenderAdapter.java
 Wed Apr 16 03:17:58 2008
@@ -22,11 +22,9 @@
 package org.apache.qpid.client;
 
 import javax.jms.Destination;
-import javax.jms.IllegalStateException;
 import javax.jms.InvalidDestinationException;
 import javax.jms.JMSException;
 import javax.jms.Message;
-import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.QueueSender;
 
@@ -200,19 +198,19 @@
         }
 
         AMQDestination destination = (AMQDestination) queue;
-        if (!destination.isValidated() && checkQueueBeforePublish())
+        if (!destination.isCheckedForQueueBinding() && 
checkQueueBeforePublish())
         {
 
             if (_delegate.getSession().isStrictAMQP())
             {
                 _delegate._logger.warn("AMQP does not support destination 
validation before publish, ");
-                destination.setValidated(true);
+                destination.setCheckedForQueueBinding(true);
             }
             else
             {
                 if (_delegate.isBound(destination))
                 {
-                    destination.setValidated(true);
+                    destination.setCheckedForQueueBinding(true);
                 }
                 else
                 {


Reply via email to