qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r561365 [6/10] - in /incubator/qpid/trunk/qpid: ./ cpp/ dotnet/ dotnet/Qpid.Buffer.Tests/ dotnet/Qpid.Buffer.Tests/Properties/ dotnet/Qpid.Buffer/ dotnet/Qpid.Buffer/Properties/ dotnet/Qpid.Client.Tests/ dotnet/Qpid.Client.Tests/BrokerDetai...
Date Tue, 31 Jul 2007 15:54:49 GMT
Modified: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueNotificationListener.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueNotificationListener.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueNotificationListener.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueNotificationListener.java Tue Jul 31 08:53:37 2007
@@ -1,21 +1,25 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.server.queue;
+
 
 public interface QueueNotificationListener
 {

Modified: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java Tue Jul 31 08:53:37 2007
@@ -25,6 +25,7 @@
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.messageStore.StorableQueue;
 
+import java.util.Collection;
 
 public interface QueueRegistry
 {
@@ -35,4 +36,9 @@
     void unregisterQueue(AMQShortString name) throws AMQException;
 
     AMQQueue getQueue(AMQShortString name);
+
+    Collection<AMQShortString> getQueueNames();
+
+    Collection<AMQQueue> getQueues();
+
 }

Modified: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/TransientMessageData.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/TransientMessageData.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/TransientMessageData.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/TransientMessageData.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.server.queue;

Modified: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/NonTransactionalContext.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/NonTransactionalContext.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/NonTransactionalContext.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/NonTransactionalContext.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.server.txn;

Modified: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/TransactionalContext.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/TransactionalContext.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/TransactionalContext.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/txn/TransactionalContext.java Tue Jul 31 08:53:37 2007
@@ -28,24 +28,144 @@
 import org.apache.qpid.server.store.StoreContext;
 
 /**
- * @author Robert Greig (robert.j.greig@jpmorgan.com)
+ * TransactionalContext provides a context in which transactional operations on {@link AMQMessage}s are performed.
+ * Different levels of transactional support for the delivery of messages may be provided by different implementations
+ * of this interface.
+ *
+ * <p/>The fundamental transactional operations that can be performed on a message queue are 'enqueue' and 'dequeue'.
+ * In this interface, these have been recast as the {@link #messageFullyReceived} and {@link #acknowledgeMessage}
+ * operations. This interface essentially provides a way to make enqueueing and dequeuing transactional.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities
+ * <tr><td> Explicitly accept a transaction start notification.
+ * <tr><td> Commit all pending operations in a transaction.
+ * <tr><td> Rollback all pending operations in a transaction.
+ * <tr><td> Deliver a message to a queue as part of a transaction.
+ * <tr><td> Redeliver a message to a queue as part of a transaction.
+ * <tr><td> Mark a message as acknowledged as part of a transaction.
+ * <tr><td> Accept notification that a message has been completely received as part of a transaction.
+ * <tr><td> Accept notification that a message has been fully processed as part of a transaction.
+ * <tr><td> Associate a message store context with this transaction context.
+ * </table>
+ *
+ * @todo The 'fullyReceived' and 'messageProcessed' events sit uncomfortably in the responsibilities of a transactional
+ *       context. They are non-transactional operations, used to trigger other side-effects. Consider moving them
+ *       somewhere else, a seperate interface for example.
+ *
+ * @todo This transactional context could be written as a wrapper extension to a Queue implementation, that provides
+ *       transactional management of the enqueue and dequeue operations, with added commit/rollback methods. Any
+ *       queue implementation could be made transactional by wrapping it as a transactional queue. This would mean
+ *       that the enqueue/dequeue operations do not need to be recast as deliver/acknowledge operations, which may be
+ *       conceptually neater.
+ *
+ * For example:
+ * <pre>
+ * public interface Transactional
+ * {
+ *    public void commit();
+ *    public void rollback();
+ * }
+ *
+ * public interface TransactionalQueue<E> extends Transactional, SizeableQueue<E>
+ * {}
+ *
+ * public class Queues
+ * {
+ *    ...
+ *    // For transactional messaging, take a transactional view onto the queue.
+ *    public static <E> TransactionalQueue<E> getTransactionalQueue(SizeableQueue<E> queue) { ... }
+ *
+ *    // For non-transactional messaging, take a non-transactional view onto the queue.
+ *    public static <E> TransactionalQueue<E> getNonTransactionalQueue(SizeableQueue<E> queue) { ... }
+ * }
+ * </pre>
  */
 public interface TransactionalContext
 {
+    /**
+     * Explicitly begins the transaction, if it has not already been started. {@link #commit} or {@link #rollback}
+     * should automatically begin the next transaction in the chain.
+     *
+     * @throws AMQException If the transaction cannot be started for any reason.
+     */
     void beginTranIfNecessary() throws AMQException;
 
+    /**
+     * Makes all pending operations on the transaction permanent and visible.
+     *
+     * @throws AMQException If the transaction cannot be committed for any reason.
+     */
     void commit() throws AMQException;
 
+    /**
+     * Erases all pending operations on the transaction.
+     *
+     * @throws AMQException If the transaction cannot be committed for any reason.
+     */
     void rollback() throws AMQException;
 
+    /**
+     * Delivers the specified message to the specified queue. A 'deliverFirst' flag may be set if the message is a
+     * redelivery, and should be placed on the front of the queue.
+     *
+     * <p/>This is an 'enqueue' operation.
+     *
+     * @param message      The message to deliver.
+     * @param queue        The queue to deliver the message to.
+     * @param deliverFirst <tt>true</tt> to place the message on the front of the queue for redelivery, <tt>false</tt>
+     *                     for normal FIFO message ordering.
+     *
+     * @throws AMQException If the message cannot be delivered for any reason.
+     */
     void deliver(AMQMessage message, AMQQueue queue, boolean deliverFirst) throws AMQException;
 
+    /**
+     * Acknowledges a message or many messages as delivered. All messages up to a specified one, may be acknowledged by
+     * setting the 'multiple' flag. It is also possible for the acknowledged message id to be zero, when the 'multiple'
+     * flag is set, in which case an acknowledgement up to the latest delivered message should be done.
+     *
+     * <p/>This is a 'dequeue' operation.
+     *
+     * @param deliveryTag              The id of the message to acknowledge, or zero, if using multiple acknowledgement
+     *                                 up to the latest message.
+     * @param lastDeliveryTag          The latest message delivered.
+     * @param multiple                 <tt>true</tt> if all message ids up the acknowledged one or latest delivered, are
+     *                                 to be acknowledged, <tt>false</tt> otherwise.
+     * @param unacknowledgedMessageMap The unacknowledged messages in the transaction, to remove the acknowledged message
+     *                                 from.
+     *
+     * @throws AMQException If the message cannot be acknowledged for any reason.
+     */
     void acknowledgeMessage(long deliveryTag, long lastDeliveryTag, boolean multiple,
-                            UnacknowledgedMessageMap unacknowledgedMessageMap) throws AMQException;
+        UnacknowledgedMessageMap unacknowledgedMessageMap) throws AMQException;
 
+    /**
+     * Notifies the transactional context that a message has been fully received. The actual message that was received
+     * is not specified. This event may be used to trigger a process related to the receipt of the message, for example,
+     * flushing its data to disk.
+     *
+     * @param persistent <tt>true</tt> if the received message is persistent, <tt>false</tt> otherwise.
+     *
+     * @throws AMQException If the fully received event cannot be processed for any reason.
+     */
     void messageFullyReceived(boolean persistent) throws AMQException;
 
+    /**
+     * Notifies the transactional context that a message has been delivered, succesfully or otherwise. The actual
+     * message that was delivered is not specified. This event may be used to trigger a process related to the
+     * outcome of the delivery of the message, for example, cleaning up failed deliveries.
+     *
+     * @param protocolSession The protocol session of the deliverable message.
+     *
+     * @throws AMQException If the message processed event cannot be handled for any reason.
+     */
     void messageProcessed(AMQProtocolSession protocolSession) throws AMQException;
 
+    /**
+     * Gets the message store context associated with this transactional context.
+     *
+     * @return The message store context associated with this transactional context.
+     */
     StoreContext getStoreContext();
 }

Modified: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java Tue Jul 31 08:53:37 2007
@@ -1,3 +1,4 @@
+<<<<<<< .working
 /*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -286,3 +287,264 @@
     }
 }
 
+=======
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.virtualhost;
+
+import javax.management.NotCompliantMBeanException;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.AMQBrokerManagerMBean;
+import org.apache.qpid.server.security.access.AccessManager;
+import org.apache.qpid.server.security.access.AccessManagerImpl;
+import org.apache.qpid.server.security.access.Accessable;
+import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
+import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
+import org.apache.qpid.server.configuration.Configurator;
+import org.apache.qpid.server.exchange.DefaultExchangeFactory;
+import org.apache.qpid.server.exchange.DefaultExchangeRegistry;
+import org.apache.qpid.server.exchange.ExchangeFactory;
+import org.apache.qpid.server.exchange.ExchangeRegistry;
+import org.apache.qpid.server.management.AMQManagedObject;
+import org.apache.qpid.server.management.ManagedObject;
+import org.apache.qpid.server.queue.DefaultQueueRegistry;
+import org.apache.qpid.server.queue.QueueRegistry;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.store.MessageStore;
+
+public class VirtualHost implements Accessable
+{
+    private static final Logger _logger = Logger.getLogger(VirtualHost.class);
+
+
+    private final String _name;
+
+    private QueueRegistry _queueRegistry;
+
+    private ExchangeRegistry _exchangeRegistry;
+
+    private ExchangeFactory _exchangeFactory;
+
+    private MessageStore _messageStore;
+
+    protected VirtualHostMBean _virtualHostMBean;
+
+    private AMQBrokerManagerMBean _brokerMBean;
+
+    private AuthenticationManager _authenticationManager;
+
+    private AccessManager _accessManager;
+
+
+    public void setAccessableName(String name)
+    {
+        _logger.warn("Setting Accessable Name for VirualHost is not allowed. ("
+                     + name + ") ignored remains :" + getAccessableName());
+    }
+
+    public String getAccessableName()
+    {
+        return _name;
+    }
+
+
+    /**
+     * Abstract MBean class. This has some of the methods implemented from management intrerface for exchanges. Any
+     * implementaion of an Exchange MBean should extend this class.
+     */
+    public class VirtualHostMBean extends AMQManagedObject implements ManagedVirtualHost
+    {
+        public VirtualHostMBean() throws NotCompliantMBeanException
+        {
+            super(ManagedVirtualHost.class, "VirtualHost");
+        }
+
+        public String getObjectInstanceName()
+        {
+            return _name.toString();
+        }
+
+        public String getName()
+        {
+            return _name.toString();
+        }
+
+        public VirtualHost getVirtualHost()
+        {
+            return VirtualHost.this;
+        }
+
+
+    } // End of MBean class
+
+    /**
+     * Used for testing only
+     * @param name
+     * @param store
+     * @throws Exception
+     */
+    public VirtualHost(String name, MessageStore store) throws Exception
+    {
+        this(name, null, store);
+    }
+
+    /**
+     * Normal Constructor
+     * @param name
+     * @param hostConfig
+     * @throws Exception
+     */
+    public VirtualHost(String name, Configuration hostConfig) throws Exception
+    {
+        this(name, hostConfig, null);
+    }
+
+    private VirtualHost(String name, Configuration hostConfig, MessageStore store) throws Exception
+    {
+        _name = name;
+
+        _virtualHostMBean = new VirtualHostMBean();
+        // This isn't needed to be registered
+        //_virtualHostMBean.register();
+
+        _queueRegistry = new DefaultQueueRegistry(this);
+        _exchangeFactory = new DefaultExchangeFactory(this);
+        _exchangeRegistry = new DefaultExchangeRegistry(this);
+
+        if (store != null)
+        {
+            _messageStore = store;
+        }
+        else
+        {
+            if (hostConfig == null)
+            {
+                throw new IllegalAccessException("HostConfig and MessageStore cannot be null");
+            }
+            initialiseMessageStore(hostConfig);
+        }
+
+        _exchangeRegistry.initialise();
+
+        _authenticationManager = new PrincipalDatabaseAuthenticationManager(name, hostConfig);
+
+        _accessManager = new AccessManagerImpl(name, hostConfig);
+
+        _brokerMBean = new AMQBrokerManagerMBean(_virtualHostMBean);
+        _brokerMBean.register();
+    }
+
+    private void initialiseMessageStore(Configuration config) throws Exception
+    {
+        String messageStoreClass = config.getString("store.class");
+
+        Class clazz = Class.forName(messageStoreClass);
+        Object o = clazz.newInstance();
+
+        if (!(o instanceof MessageStore))
+        {
+            throw new ClassCastException("Message store class must implement " + MessageStore.class + ". Class " + clazz +
+                                         " does not.");
+        }
+        _messageStore = (MessageStore) o;
+        _messageStore.configure(this, "store", config);
+    }
+
+
+    public <T> T getConfiguredObject(Class<T> instanceType, Configuration config)
+    {
+        T instance;
+        try
+        {
+            instance = instanceType.newInstance();
+        }
+        catch (Exception e)
+        {
+            _logger.error("Unable to instantiate configuration class " + instanceType + " - ensure it has a public default constructor");
+            throw new IllegalArgumentException("Unable to instantiate configuration class " + instanceType + " - ensure it has a public default constructor", e);
+        }
+        Configurator.configure(instance);
+
+        return instance;
+    }
+
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public QueueRegistry getQueueRegistry()
+    {
+        return _queueRegistry;
+    }
+
+    public ExchangeRegistry getExchangeRegistry()
+    {
+        return _exchangeRegistry;
+    }
+
+    public ExchangeFactory getExchangeFactory()
+    {
+        return _exchangeFactory;
+    }
+
+    public ApplicationRegistry getApplicationRegistry()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public MessageStore getMessageStore()
+    {
+        return _messageStore;
+    }
+
+    public AuthenticationManager getAuthenticationManager()
+    {
+        return _authenticationManager;
+    }
+
+    public AccessManager getAccessManager()
+    {
+        return _accessManager;
+    }
+
+    public void close() throws Exception
+    {
+        if (_messageStore != null)
+        {
+            _messageStore.close();
+        }
+    }
+
+    public ManagedObject getBrokerMBean()
+    {
+        return _brokerMBean;
+    }
+
+    public ManagedObject getManagedObject()
+    {
+        return _virtualHostMBean;
+    }
+}
+>>>>>>> .merge-right.r553432

Copied: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java (from r553432, incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java?view=diff&rev=561365&p1=incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java&r1=553432&p2=incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java&r2=561365
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/MessageStoreTool.java Tue Jul 31 08:53:37 2007
@@ -32,6 +32,7 @@
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.tools.messagestore.commands.Clear;
 import org.apache.qpid.tools.messagestore.commands.Command;
+import org.apache.qpid.tools.messagestore.commands.Copy;
 import org.apache.qpid.tools.messagestore.commands.Dump;
 import org.apache.qpid.tools.messagestore.commands.Help;
 import org.apache.qpid.tools.messagestore.commands.List;
@@ -56,7 +57,9 @@
 import java.io.OutputStreamWriter;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 /**
  * MessageStoreTool.
@@ -85,6 +88,7 @@
 
     /** Control used for main run loop. */
     private boolean _running = true;
+    private boolean _initialised = false;
 
     //---------------------------------------------------------------------------------------------------/
 
@@ -182,13 +186,16 @@
 
     public void quit()
     {
-        ApplicationRegistry.remove(1);
+        _running = false;
+
+        if (_initialised)
+        {
+            ApplicationRegistry.remove(1);
+        }
 
         _console.println("...exiting");
 
         _console.close();
-
-        _running = false;
     }
 
     public void setBatchMode(boolean batchmode)
@@ -203,6 +210,15 @@
     {
         setup();
 
+        if (!_initialised)
+        {
+            System.exit(1);
+        }
+
+        _console.println("");
+
+        _console.println(BOILER_PLATE);        
+
         runCLI();
     }
 
@@ -212,8 +228,6 @@
 
         loadCommands();
 
-        _console.println(BOILER_PLATE);
-
         _state.clearAll();
     }
 
@@ -222,6 +236,7 @@
         _commands.clear();
         //todo Dynamically load the classes that exis in com.redhat.etp.qpid.commands
         _commands.put("close", new Clear(this));
+        _commands.put("copy", new Copy(this));
         _commands.put("dump", new Dump(this));
         _commands.put("help", new Help(this));
         _commands.put("list", new List(this));
@@ -256,9 +271,11 @@
             ConfigurationFileApplicationRegistry registry = new ConfigurationFileApplicationRegistry(configFile);
 
             ApplicationRegistry.remove(1);
+
             ApplicationRegistry.initialise(registry);
 
             checkMessageStores();
+            _initialised = true;
         }
         catch (ConfigurationException e)
         {
@@ -314,12 +331,15 @@
             {
                 exec(args);
 
-                if (!_batchMode)
+                if (_running)
                 {
-                    printPrompt();
-                }
+                    if (!_batchMode)
+                    {
+                        printPrompt();
+                    }
 
-                args = _console.readCommand();
+                    args = _console.readCommand();
+                }
             }
         }
     }
@@ -571,6 +591,47 @@
         public void clearMessages()
         {
             _msgids = null;
+        }
+
+        /**
+         * A common location to provide parsing of the message id string
+         * utilised by a number of the commands.
+         * The String is comma separated list of ids that can be individual ids
+         * or a range (4-10)
+         *
+         * @param msgString string of msg ids to parse 1,2,4-10
+         */
+        public void setMessages(String msgString)
+        {
+            StringTokenizer tok = new StringTokenizer(msgString, ",");
+
+            if (tok.hasMoreTokens())
+            {
+                _msgids = new LinkedList<Long>();
+            }
+
+            while (tok.hasMoreTokens())
+            {
+                String next = tok.nextToken();
+                if (next.contains("-"))
+                {
+                    Long start = Long.parseLong(next.substring(0, next.indexOf("-")));
+                    Long end = Long.parseLong(next.substring(next.indexOf("-") + 1));
+
+                    if (end >= start)
+                    {
+                        for (long l = start; l <= end; l++)
+                        {
+                            _msgids.add(l);
+                        }
+                    }
+                }
+                else
+                {
+                    _msgids.add(Long.parseLong(next));
+                }
+            }
+
         }
 
         public void setMessages(java.util.List<Long> msgids)

Copied: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Dump.java (from r553432, incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Dump.java)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Dump.java?view=diff&rev=561365&p1=incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Dump.java&r1=553432&p2=incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Dump.java&r2=561365
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Dump.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Dump.java Tue Jul 31 08:53:37 2007
@@ -54,7 +54,7 @@
 
     public String usage()
     {
-        return getCommand() + " [show=[all],[msgheaders],[_amqHeaders],[routing],[content] id=<msgid e.g. 1,2,4-10>";
+        return getCommand() + " [show=[all],[msgheaders],[_amqHeaders],[routing],[content]] [id=<msgid e.g. 1,2,4-10>]";
     }
 
     public String getCommand()

Copied: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Help.java (from r553432, incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Help.java)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Help.java?view=diff&rev=561365&p1=incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Help.java&r1=553432&p2=incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Help.java&r2=561365
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Help.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Help.java Tue Jul 31 08:53:37 2007
@@ -35,7 +35,7 @@
 
     public String help()
     {
-        return "Provides detailed help on commands. ";
+        return "Provides detailed help on commands.";
     }
 
     public String getCommand()
@@ -59,6 +59,7 @@
             if (command != null)
             {
                 _console.println(command.help());
+                _console.println("Usage:" + command.usage());
             }
             else
             {

Copied: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/List.java (from r553432, incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/List.java)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/List.java?view=diff&rev=561365&p1=incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/List.java&r1=553432&p2=incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/List.java&r2=561365
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/List.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/List.java Tue Jul 31 08:53:37 2007
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.tools.messagestore.commands;
 
-import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.queue.AMQQueue;
@@ -47,12 +46,12 @@
 
     public String help()
     {
-        return "list availble items.";
+        return "list available items.";
     }
 
     public String usage()
     {
-        return "list queues [<exchange>] | exchanges| bindings [<exchange>] | all.";
+        return "list queues [<exchange>] | exchanges | bindings [<exchange>] | all";
     }
 
     public String getCommand()
@@ -234,17 +233,9 @@
         {
             if (exchange != null)
             {
-                try
+                if (exchange.isBound(queue))
                 {
-                    if (exchange.isBound(queue))
-                    {
-                        data.add(queue.toString());
-                    }
-                }
-                catch (AMQException e)
-                {
-                    // is never thrown by current impls forced to throw by interface.
-                    commandError("Unable to check exchange bindings: " + e.getMessage(), null);
+                    data.add(queue.toString());
                 }
             }
             else
@@ -299,17 +290,9 @@
         {
             if (exchange != null)
             {
-                try
-                {
-                    if (exchange.isBound(queue))
-                    {
-                        data.add(queue.getName().toString());
-                    }
-                }
-                catch (AMQException e)
+                if (exchange.isBound(queue))
                 {
-                    // is never thrown by current impls forced to throw by interface.
-                    commandError("Unable to check exchange bindings: " + e.getMessage(), null);
+                    data.add(queue.getName().toString());
                 }
             }
             else

Copied: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java (from r553432, incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java?view=diff&rev=561365&p1=incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java&r1=553432&p2=incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java&r2=561365
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Select.java Tue Jul 31 08:53:37 2007
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.tools.messagestore.commands;
 
-import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.queue.AMQQueue;
@@ -41,12 +40,12 @@
 
     public String help()
     {
-        return "Perform a selection";
+        return "Perform a selection.";
     }
 
     public String usage()
     {
-        return "select virtualhost <name> |exchange <name> |queue <name> | msgs id=< msgids eg. 1,2,4-10 >";
+        return "select virtualhost <name> |exchange <name> |queue <name> | msgs id=<msgids eg. 1,2,4-10>";
     }
 
     public String getCommand()
@@ -132,16 +131,9 @@
 
             if (_tool.getState().getQueue() != null)
             {
-                try
+                if (!exchange.isBound(_tool.getState().getQueue()))
                 {
-                    if (!exchange.isBound(_tool.getState().getQueue()))
-                    {
-                        _tool.getState().setQueue(null);
-                    }
-                }
-                catch (AMQException e)
-                {
-                    //ignore
+                    _tool.getState().setQueue(null);
                 }
             }
         }
@@ -170,24 +162,17 @@
                 {
                     for (AMQShortString exchangeName : vhost.getExchangeRegistry().getExchangeNames())
                     {
-                        try
-                        {
-                            Exchange exchange = vhost.getExchangeRegistry().getExchange(exchangeName);
-                            if (exchange.isBound(queue))
-                            {
-                                _tool.getState().setExchange(exchange);
-                                break;
-                            }
-                        }
-                        catch (AMQException e)
+                        Exchange exchange = vhost.getExchangeRegistry().getExchange(exchangeName);
+                        if (exchange.isBound(queue))
                         {
-                            //ignore error
+                            _tool.getState().setExchange(exchange);
+                            break;
                         }
                     }
                 }
 
                 //remove the message selection
-                _tool.getState().setMessages(null);
+                _tool.getState().setMessages((java.util.List<Long>) null);
             }
         }
 

Copied: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Show.java (from r553432, incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Show.java)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Show.java?view=diff&rev=561365&p1=incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Show.java&r1=553432&p2=incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Show.java&r2=561365
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Show.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/messagestore/commands/Show.java Tue Jul 31 08:53:37 2007
@@ -52,7 +52,7 @@
 
     public String usage()
     {
-        return getCommand() + " [show=[all],[msgheaders],[amqheaders],[routing] id=<msgid e.g. 1,2,4-10>";
+        return getCommand() + " [show=[all],[msgheaders],[amqheaders],[routing]] [id=<msgid e.g. 1,2,4-10>]";
     }
 
     public String getCommand()
@@ -94,35 +94,6 @@
 
                 if (arg.startsWith("id="))
                 {
-                    StringTokenizer tok = new StringTokenizer(arg.substring(arg.indexOf("=") + 1), ",");
-
-                    if (tok.hasMoreTokens())
-                    {
-                        msgids = new LinkedList<Long>();
-                    }
-
-                    while (tok.hasMoreTokens())
-                    {
-                        String next = tok.nextToken();
-                        if (next.contains("-"))
-                        {
-                            Long start = Long.parseLong(next.substring(0, next.indexOf("-")));
-                            Long end = Long.parseLong(next.substring(next.indexOf("-") + 1));
-
-                            if (end >= start)
-                            {
-                                for (long l = start; l <= end; l++)
-                                {
-                                    msgids.add(l);
-                                }
-                            }
-                        }
-                        else
-                        {
-                            msgids.add(Long.parseLong(next));
-                        }
-                    }
-
                     _tool.getState().setMessages(msgids);
                 }
             }//for args
@@ -133,7 +104,7 @@
     {
         if (_tool.getState().getVhost() == null)
         {
-            _console.println("No Virtualhost open. Open a Virtualhost first.");
+            _console.println("No Virtualhost selected. 'DuSelect' a Virtualhost first.");
             return;
         }
 

Copied: incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/utils/SimpleCommandParser.java (from r553432, incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/utils/SimpleCommandParser.java)
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/utils/SimpleCommandParser.java?view=diff&rev=561365&p1=incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/utils/SimpleCommandParser.java&r1=553432&p2=incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/utils/SimpleCommandParser.java&r2=561365
==============================================================================
--- incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/tools/utils/SimpleCommandParser.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/tools/utils/SimpleCommandParser.java Tue Jul 31 08:53:37 2007
@@ -65,6 +65,11 @@
             _nextCommand = null;
         }
 
+        if (input == null)
+        {
+            return null;
+        }
+
         StringTokenizer tok = new StringTokenizer(input, " ");
 
         int tokenCount = tok.countTokens();

Modified: incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/ExchangeMBeanTest.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.server.exchange;

Modified: incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/TestMinaProtocolSession.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/TestMinaProtocolSession.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/TestMinaProtocolSession.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/TestMinaProtocolSession.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.server.protocol;

Modified: incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.server.queue;

Modified: incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java (original)
+++ incubator/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.server.queue;

Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java (original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorMessageDispatcher.java Tue Jul 31 08:53:37 2007
@@ -18,18 +18,18 @@
  */
 package org.apache.qpid.example.publisher;
 
-import org.apache.log4j.Logger;
 import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Logger;
 
-import javax.jms.*;
-
-import java.util.Properties;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
 
 /**
- * Class that sends heartbeat messages to allow monitoring of message consumption
- * Sends regular (currently 20 seconds apart) heartbeat message
+ * Class that sends heartbeat messages to allow monitoring of message consumption Sends regular (currently 20 seconds
+ * apart) heartbeat message
  */
-public class MonitorMessageDispatcher {
+public class MonitorMessageDispatcher
+{
 
     private static final Logger _logger = Logger.getLogger(MonitorMessageDispatcher.class);
 
@@ -39,17 +39,18 @@
 
     /**
      * Easy entry point for running a message dispatcher for monitoring consumption
+     *
      * @param args
      */
     public static void main(String[] args)
     {
-
         //Switch on logging appropriately for your app
         BasicConfigurator.configure();
 
         try
         {
-            while(true)
+            int i =0;
+            while (i < 1000)
             {
                 try
                 {
@@ -62,9 +63,10 @@
                     }
 
                     //sleep for twenty seconds and then publish again - change if appropriate
-                    Thread.sleep(20000);
+                    //Thread.sleep(1000);
+                    i++   ;
                 }
-                catch(UndeliveredMessageException a)
+                catch (UndeliveredMessageException a)
                 {
                     //trigger application specific failure handling here
                     _logger.error("Problem delivering monitor message");
@@ -72,7 +74,7 @@
                 }
             }
         }
-        catch(Exception e)
+        catch (Exception e)
         {
             _logger.error("Error trying to dispatch AMS monitor message: " + e);
             System.exit(1);
@@ -81,7 +83,7 @@
         {
             if (getMonitorPublisher() != null)
             {
-               getMonitorPublisher().cleanup();
+                getMonitorPublisher().cleanup();
             }
         }
 
@@ -90,19 +92,24 @@
 
     /**
      * Publish heartbeat message
+     *
      * @throws JMSException
      * @throws UndeliveredMessageException
      */
     public static void publish() throws JMSException, UndeliveredMessageException
     {
         //Send the message generated from the payload using the _publisher
-        getMonitorPublisher().sendImmediateMessage
-          (FileMessageFactory.createSimpleEventMessage(getMonitorPublisher().getSession(),"monitor:" +System.currentTimeMillis()));
+//        getMonitorPublisher().sendImmediateMessage
+//          (FileMessageFactory.createSimpleEventMessage(getMonitorPublisher().getSession(),"monitor:" +System.currentTimeMillis()));
+
+        getMonitorPublisher().sendMessage
+                (getMonitorPublisher()._session,
+                 FileMessageFactory.createSimpleEventMessage(getMonitorPublisher().getSession(), "monitor:" + System.currentTimeMillis()),
+                 DeliveryMode.PERSISTENT, false, true);
+
     }
 
-    /**
-     * Cleanup publishers
-     */
+    /** Cleanup publishers */
     public static void cleanup()
     {
         if (getMonitorPublisher() != null)
@@ -119,16 +126,16 @@
     //Returns a _publisher for the monitor queue
     private static MonitorPublisher getMonitorPublisher()
     {
-       if (_monitorPublisher != null)
-       {
-           return _monitorPublisher;
-       }
+        if (_monitorPublisher != null)
+        {
+            return _monitorPublisher;
+        }
 
-       //Create a _publisher using failover details and constant for monitor queue
-       _monitorPublisher = new MonitorPublisher();
+        //Create a _publisher using failover details and constant for monitor queue
+        _monitorPublisher = new MonitorPublisher();
 
-       _monitorPublisher.setName(MonitorMessageDispatcher.DEFAULT_MONITOR_PUB_NAME);
-       return _monitorPublisher;
+        _monitorPublisher.setName(MonitorMessageDispatcher.DEFAULT_MONITOR_PUB_NAME);
+        return _monitorPublisher;
     }
 
 }

Modified: incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorPublisher.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorPublisher.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorPublisher.java (original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/publisher/MonitorPublisher.java Tue Jul 31 08:53:37 2007
@@ -18,15 +18,17 @@
  */
 package org.apache.qpid.example.publisher;
 
-import javax.jms.Message;
+import org.apache.log4j.Logger;
+import org.apache.qpid.client.BasicMessageProducer;
+
 import javax.jms.DeliveryMode;
 import javax.jms.JMSException;
-import org.apache.qpid.client.BasicMessageProducer;
-import org.apache.log4j.Logger;
+import javax.jms.Message;
+import javax.jms.Session;
 
 /**
- * Subclass of Publisher which uses QPID functionality to send a heartbeat message
- * Note immediate flag not available via JMS MessageProducer
+ * Subclass of Publisher which uses QPID functionality to send a heartbeat message Note immediate flag not available via
+ * JMS MessageProducer
  */
 public class MonitorPublisher extends Publisher
 {
@@ -40,14 +42,45 @@
         super();
     }
 
-     /*
-     * Publishes a non-persistent message using transacted session
-     */
+    /*
+    * Publishes a message using given details
+    */
+    public boolean sendMessage(Session session, Message message, int deliveryMode,
+                                        boolean immediate, boolean commit) throws UndeliveredMessageException
+    {
+        try
+        {
+            _producer = (BasicMessageProducer) session.createProducer(_destination);
+
+            _producer.send(message, deliveryMode, immediate);
+
+            if (commit)
+            {
+                //commit the message send and close the transaction
+                _session.commit();
+            }
+
+        }
+        catch (JMSException e)
+        {
+            //Have to assume our commit failed but do not rollback here as channel closed
+            _log.error(e);
+            e.printStackTrace();
+            throw new UndeliveredMessageException("Cannot deliver immediate message", e);
+        }
+
+        _log.info(_name + " finished sending message: " + message);
+        return true;
+    }
+
+    /*
+    * Publishes a non-persistent message using transacted session
+    */
     public boolean sendImmediateMessage(Message message) throws UndeliveredMessageException
     {
         try
         {
-             _producer = (BasicMessageProducer)_session.createProducer(_destination);
+            _producer = (BasicMessageProducer) _session.createProducer(_destination);
 
             //Send message via our producer which is not persistent and is immediate
             //NB: not available via jms interface MessageProducer
@@ -62,7 +95,7 @@
             //Have to assume our commit failed but do not rollback here as channel closed
             _log.error(e);
             e.printStackTrace();
-            throw new UndeliveredMessageException("Cannot deliver immediate message",e);
+            throw new UndeliveredMessageException("Cannot deliver immediate message", e);
         }
 
         _log.info(_name + " finished sending message: " + message);

Modified: incubator/qpid/trunk/qpid/java/client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/pom.xml?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/pom.xml (original)
+++ incubator/qpid/trunk/qpid/java/client/pom.xml Tue Jul 31 08:53:37 2007
@@ -123,6 +123,50 @@
 
     <build>
         <plugins>
+
+           <plugin>
+                <artifactId>minijar-maven-plugin</artifactId>
+                <groupId>org.codehaus.mojo</groupId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>ueberjar</goal>
+                        </goals>
+                        <configuration>
+                            <stripUnusedClasses>false</stripUnusedClasses>
+                            <name>[artifactId]-[version]-single.jar</name>
+                            <classifier>single</classifier>
+                            <attach>true</attach>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                  <execution>
+                    <id>attach-artifacts</id>
+                    <phase>package</phase>
+                    <goals>
+                      <goal>attach-artifact</goal>
+                    </goals>
+                    <configuration>
+                        <artifacts>
+                          <artifact>
+                            <file>target/${artifactId}-${version}-single.jar</file>
+                            <type>jar</type>
+                            <classifier>single</classifier>
+                          </artifact>
+                        </artifacts>
+                    </configuration>
+                  </execution>
+                </executions>
+            </plugin>
+
+
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java Tue Jul 31 08:53:37 2007
@@ -46,7 +46,6 @@
 import org.apache.qpid.jms.FailoverPolicy;
 import org.apache.qpid.protocol.AMQConstant;
 import org.apache.qpid.url.URLSyntaxException;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -68,7 +67,6 @@
 import javax.naming.Reference;
 import javax.naming.Referenceable;
 import javax.naming.StringRefAddr;
-
 import java.io.IOException;
 import java.net.ConnectException;
 import java.nio.channels.UnresolvedAddressException;
@@ -1148,7 +1146,7 @@
         }
         else
         {
-            _logger.info("Not a hard-error connection not closing.");
+            _logger.info("Not a hard-error connection not closing: " + cause.getMessage());
         }
     }
 

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java Tue Jul 31 08:53:37 2007
@@ -20,6 +20,14 @@
  */
 package org.apache.qpid.client;
 
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.jms.ConnectionURL;
+import org.apache.qpid.url.URLHelper;
+import org.apache.qpid.url.URLSyntaxException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.HashMap;
@@ -27,14 +35,10 @@
 import java.util.List;
 import java.util.StringTokenizer;
 
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.jms.BrokerDetails;
-import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.url.URLHelper;
-import org.apache.qpid.url.URLSyntaxException;
-
 public class AMQConnectionURL implements ConnectionURL
 {
+    private static final Logger _logger = LoggerFactory.getLogger(AMQConnectionURL.class);
+
     private String _url;
     private String _failoverMethod;
     private HashMap<String, String> _failoverOptions;
@@ -162,7 +166,7 @@
                 if ((slash != 0) && (fullURL.charAt(slash - 1) == ':'))
                 {
                     throw URLHelper.parseError(slash - 2, fullURL.indexOf('?') - slash + 2,
-                        "Virtual host looks like a windows path, forward slash not allowed in URL", fullURL);
+                                               "Virtual host looks like a windows path, forward slash not allowed in URL", fullURL);
                 }
                 else
                 {
@@ -182,7 +186,7 @@
         if (colonIndex == -1)
         {
             throw URLHelper.parseError(AMQ_PROTOCOL.length() + 3, userinfo.length(),
-                "Null password in user information not allowed.", _url);
+                                       "Null password in user information not allowed.", _url);
         }
         else
         {
@@ -387,7 +391,14 @@
             if (_password != null)
             {
                 sb.append(':');
-                sb.append(_password);
+                if (_logger.isDebugEnabled())
+                {
+                    sb.append(_password);
+                }
+                else
+                {
+                    sb.append("********");
+                }
             }
 
             sb.append('@');
@@ -432,7 +443,7 @@
     public static void main(String[] args) throws URLSyntaxException
     {
         String url2 =
-            "amqp://ritchiem:bob@temp?brokerlist='tcp://localhost:5672;jcp://fancyserver:3000/',failover='roundrobin'";
+                "amqp://ritchiem:bob@temp?brokerlist='tcp://localhost:5672;jcp://fancyserver:3000/',failover='roundrobin'";
         // "amqp://user:pass@clientid/virtualhost?brokerlist='tcp://host:1?option1=\'value\',option2=\'value\';vm://:3?option1=\'value\'',failover='method?option1=\'value\',option2='value''";
 
         ConnectionURL connectionurl2 = new AMQConnectionURL(url2);

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java Tue Jul 31 08:53:37 2007
@@ -2319,6 +2319,16 @@
         }
     }
 
+    public void declareAndBind(AMQDestination amqd)
+            throws
+            AMQException
+    {
+        AMQProtocolHandler protocolHandler = getProtocolHandler();
+        declareExchange(amqd, protocolHandler, false);
+        AMQShortString queueName = declareQueue(amqd, protocolHandler);
+        bindQueue(queueName, amqd.getRoutingKey(), new FieldTable(), amqd.getExchangeName());
+    }
+
     /**
      * Callers must hold the failover mutex before calling this method.
      *

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ExchangeBoundOkMethodHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ExchangeBoundOkMethodHandler.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ExchangeBoundOkMethodHandler.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/ExchangeBoundOkMethodHandler.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.client.handler;

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/QueueDeleteOkMethodHandler.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/QueueDeleteOkMethodHandler.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/QueueDeleteOkMethodHandler.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/handler/QueueDeleteOkMethodHandler.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.client.handler;

Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/CloseWithBlockingReceiveTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/CloseWithBlockingReceiveTest.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/CloseWithBlockingReceiveTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/channelclose/CloseWithBlockingReceiveTest.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.test.unit.client.channelclose;

Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/forwardall/CombinedTest.java Tue Jul 31 08:53:37 2007
@@ -21,9 +21,7 @@
 package org.apache.qpid.test.unit.client.forwardall;
 
 import junit.framework.TestCase;
-
 import org.apache.qpid.testutil.VMBrokerSetup;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,6 +32,7 @@
 public class CombinedTest extends TestCase
 {
     private static final Logger _logger = LoggerFactory.getLogger(CombinedTest.class);
+    private int run = 0;
 
     protected void setUp() throws Exception
     {
@@ -48,14 +47,18 @@
 
     public void testForwardAll() throws Exception
     {
-        int services = 2;
-        ServiceCreator.start("vm://:1", services);
+        while (run < 10)
+        {
+            int services = 2;
+            ServiceCreator.start("vm://:1", services);
+
+            _logger.info("Starting " + ++run + " client...");
 
-        _logger.info("Starting client...");
+            new Client("vm://:1", services).shutdownWhenComplete();
 
-        new Client("vm://:1", services).shutdownWhenComplete();
 
-        _logger.info("Completed successfully!");
+            _logger.info("Completed " + run + " successfully!");
+        }
     }
 
     public static junit.framework.Test suite()

Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/transacted/CommitRollbackTest.java Tue Jul 31 08:53:37 2007
@@ -21,12 +21,10 @@
 package org.apache.qpid.test.unit.transacted;
 
 import junit.framework.TestCase;
-
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.transport.TransportConnection;
 import org.apache.qpid.url.URLSyntaxException;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -57,6 +55,9 @@
 
     private static final Logger _logger = LoggerFactory.getLogger(CommitRollbackTest.class);
     private static final String BROKER = "vm://:1";
+    private boolean _gotone = false;
+    private boolean _gottwo = false;
+    private boolean _gottwoRedelivered = false;
 
     protected void setUp() throws Exception
     {
@@ -340,57 +341,98 @@
      *
      * @throws Exception On error
      */
-    /*public void testSend2ThenRollback() throws Exception
+    public void testSend2ThenRollback() throws Exception
     {
-        assertTrue("session is not transacted", _session.getTransacted());
-        assertTrue("session is not transacted", _pubSession.getTransacted());
+        int run = 0;
+        while (run < 10)
+        {
+            run++;
+            _logger.info("Run:" + run);
+            assertTrue("session is not transacted", _session.getTransacted());
+            assertTrue("session is not transacted", _pubSession.getTransacted());
+
+            _logger.info("sending two test messages");
+            _publisher.send(_pubSession.createTextMessage("1"));
+            _publisher.send(_pubSession.createTextMessage("2"));
+            _pubSession.commit();
 
-        _logger.info("sending two test messages");
-        _publisher.send(_pubSession.createTextMessage("1"));
-        _publisher.send(_pubSession.createTextMessage("2"));
-        _pubSession.commit();
+            _logger.info("getting test message");
+            assertEquals("1", ((TextMessage) _consumer.receive(1000)).getText());
 
-        _logger.info("getting test message");
-        assertEquals("1", ((TextMessage) _consumer.receive(1000)).getText());
+            _logger.info("rolling back");
+            _session.rollback();
 
-        _logger.info("rolling back");
-        _session.rollback();
+            _logger.info("receiving result");
+            Message result = _consumer.receive(1000);
 
-        _logger.info("receiving result");
-        Message result = _consumer.receive(1000);
+            assertNotNull("test message was consumed and rolled back, but is gone", result);
 
-        assertNotNull("test message was consumed and rolled back, but is gone", result);
+            // Message Order is:
+
+            // Send 1 , 2
+            // Retrieve 1 and then rollback
+            // Receieve 1 (redelivered) , 2 (may or may not be redelivered??)
+
+            verifyMessages(result);
+
+            // Occassionally get message 2 first!
+//            assertEquals("Should get message one first", "1", ((TextMessage) result).getText());
+//            assertTrue("Message is not marked as redelivered", result.getJMSRedelivered());
+//
+//            result = _consumer.receive(1000);
+//            assertEquals("Second message should be message 2", "2", ((TextMessage) result).getText());
+//            assertTrue("Message is not marked as redelivered", result.getJMSRedelivered());
+//
+//            result = _consumer.receive(1000);
+//            assertNull("There should be no more messages", result);
+
+            _session.commit();
+        }
+    }
 
+    private void verifyMessages(Message result) throws JMSException
+    {
 
-        if (((TextMessage) result).getText().equals("2"))
+        if (result == null)
         {
-            assertTrue("Messasge is marked as redelivered", !result.getJMSRedelivered());
+            assertTrue("Didn't receive redelivered message one", _gotone);
+            assertTrue("Didn't receive message two at all", _gottwo | _gottwoRedelivered);
+            _gotone = false;
+            _gottwo = false;
+            _gottwoRedelivered = false;
+            return;
+        }
+
+        if (((TextMessage) result).getText().equals("1"))
+        {
+            _logger.info("Got 1 redelivered");
+            assertTrue("Message is not marked as redelivered", result.getJMSRedelivered());
+            assertFalse("Already received message one", _gotone);
+            _gotone = true;
 
-            result = _consumer.receive(1000);
-            assertEquals("1", ((TextMessage) result).getText());
-            assertTrue("Messasge is not marked as redelivered", result.getJMSRedelivered());
         }
         else
         {
-            assertEquals("1", ((TextMessage) result).getText());
-            assertTrue("Messasge is not marked as redelivered", result.getJMSRedelivered());
-            result = _consumer.receive(1000);
-            assertNotNull("test message was consumed and rolled back, but is gone", result);
             assertEquals("2", ((TextMessage) result).getText());
-            assertTrue("Messasge is not marked as redelivered", result.getJMSRedelivered());
-        }
 
-        result = _consumer.receive(1000);
+            if (result.getJMSRedelivered())
+            {
+                _logger.info("Got 2 redelivered, message was prefetched");
+                assertFalse("Already received message redelivered two", _gottwoRedelivered);
+
+                _gottwoRedelivered = true;
+            }
+            else
+            {
+                _logger.warn("Got 2, message prefetched wasn't cleared or messages was in transit when rollback occured");                
+                assertFalse("Already received message two", _gottwo);
 
-        if (result != null)
-        {
-            assertEquals("2", ((TextMessage) result).getText());
-            assertTrue("Messasge is not marked as redelivered", result.getJMSRedelivered());
-            result = _consumer.receive(1000);
+                _gottwo = true;
+            }
         }
 
-        assertNull("test message should be null", result);
-    }*/
+        verifyMessages(_consumer.receive(1000));
+    }
 
     public void testSend2ThenCloseAfter1andTryAgain() throws Exception
     {
@@ -417,12 +459,12 @@
 
         _logger.info("receiving result");
 
-        // NOTE: Both msg 1 & 2 will be marked as redelivered as they have both will have been rejected.
-        // Only the occasion where it is not rejected will it mean it hasn't arrived at the client yet.
+// NOTE: Both msg 1 & 2 will be marked as redelivered as they have both will have been rejected.
+// Only the occasion where it is not rejected will it mean it hasn't arrived at the client yet.
         result = _consumer.receive(1000);
         assertNotNull("test message was consumed and rolled back, but is gone", result);
 
-        // The first message back will be either 1 or 2 being redelivered
+// The first message back will be either 1 or 2 being redelivered
         if (result.getJMSRedelivered())
         {
             assertTrue("Messasge is not marked as redelivered" + result, result.getJMSRedelivered());

Modified: incubator/qpid/trunk/qpid/java/cluster/src/main/java/org/apache/qpid/server/cluster/SimpleBodySendable.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/cluster/src/main/java/org/apache/qpid/server/cluster/SimpleBodySendable.java?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/cluster/src/main/java/org/apache/qpid/server/cluster/SimpleBodySendable.java (original)
+++ incubator/qpid/trunk/qpid/java/cluster/src/main/java/org/apache/qpid/server/cluster/SimpleBodySendable.java Tue Jul 31 08:53:37 2007
@@ -1,18 +1,21 @@
 /*
  *
- * Copyright (c) 2006 The Apache Software Foundation
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  *
  */
 package org.apache.qpid.server.cluster;

Propchange: incubator/qpid/trunk/qpid/java/common/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Jul 31 08:53:37 2007
@@ -2,3 +2,5 @@
 intellijclasses
 target
 qpid-common.iml
+qpid-common.ipr
+qpid-common.iws

Modified: incubator/qpid/trunk/qpid/java/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/pom.xml?view=diff&rev=561365&r1=561364&r2=561365
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/pom.xml (original)
+++ incubator/qpid/trunk/qpid/java/common/pom.xml Tue Jul 31 08:53:37 2007
@@ -100,22 +100,34 @@
 
                 </executions>
             </plugin>
-            
+
         </plugins>
     </build>
 
     <dependencies>
 
-        <dependency>  
+        <dependency>
+            <groupId>commons-configuration</groupId>
+            <artifactId>commons-configuration</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-cli</groupId>
+            <artifactId>commons-cli</artifactId>
+        </dependency>
+
+
+
+        <dependency>
             <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>  
+            <artifactId>slf4j-api</artifactId>
             <version>1.4.0</version> 
         </dependency>
 
-        <dependency>  
-            <groupId>org.slf4j</groupId> 
-            <artifactId>slf4j-log4j12</artifactId>  
-            <version>1.4.0</version>  
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.4.0</version>
             <scope>test</scope> 
         </dependency>
 



Mime
View raw message