// Path: AMQPPerfHarness/src/com/ibm/uk/hursley/perfharness/amqp/AMQPWorkerThread.java
// public static class AMQPException extends Exception {
// 	private static final long serialVersionUID = 1L;
// 
// 	/**
// 	 * @param message
// 	 */
// 	public AMQPException(final String message) {
// 		super(message);
// 	}
// 		
// 	/**
// 	 * @param message
// 	 * @param cause
// 	 */
// 	public AMQPException(final String message, final Throwable cause) {
// 		super(message, cause);
// 	}
// }
// 
// Path: AMQPPerfHarness/src/com/ibm/uk/hursley/perfharness/amqp/utils/FIFO.java
// public static class FIFODelivery extends FIFOAbs {
// 	public FIFODelivery(final String reference) {
// 		super(reference);
// 	}
// 
// 	/**
// 	 * Insert an item into the FIFO
// 	 * 
// 	 * @param delivery
// 	 */
// 	public void put(final Delivery delivery) {
// 		super.put(delivery);
// 	}
// 
// 	/**
// 	 * Removes a delivery message from the FIFO
// 	 * 
// 	 * @return a delivery or null if exception.
// 	 * @throws AMQPException 
// 	 *
// 	 */
// 	public Delivery get() throws AMQPException {
// 		Object item = super.get();
// 		if (item instanceof Delivery) {
// 			return (Delivery) item;
// 		}
// 		else {
// 			throw new AMQPException("Internal error: expected Delivery but got " + item.getClass().getName());
// 		}
// 	}
// }
// 
// Path: AMQPPerfHarness/src/com/ibm/uk/hursley/perfharness/amqp/utils/FIFO.java
// public static class FIFOHashMap extends FIFOAbs {
// 	public FIFOHashMap(final String reference) {
// 		super(reference);
// 	}
// 
// 
// 	/**
// 	 * @param hashMap
// 	 */
// 	public void put(final HashMap<String, Object> hashMap) {
// 		super.put(hashMap);
// 	}
// 
// 
// 	/* (non-Javadoc)
// 	 * @see com.ibm.uk.hursley.perfharness.amqp.utils.FIFO.FIFOAbs#get()
// 	 */
// 	@SuppressWarnings("unchecked")
// 	public HashMap<String, Object> get() throws AMQPException {
// 		Object item = super.get();
// 		if (item instanceof HashMap) {
// 			return (HashMap<String, Object>) item;
// 		}
// 		else {
// 			throw new AMQPException("Internal error: expected HashMap but got " + item.getClass().getName());
// 		}
// 	}
// }
// 
// Path: AMQPPerfHarness/src/com/ibm/uk/hursley/perfharness/amqp/utils/MessageContainer.java
// public enum MESSAGE_TYPE {STRING, BYTES};


import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.logging.Level;
import com.ibm.mqlight.api.ClientException;
import com.ibm.mqlight.api.ClientOptions;
import com.ibm.mqlight.api.ClientState;
import com.ibm.mqlight.api.CompletionListener;
import com.ibm.mqlight.api.Delivery;
import com.ibm.mqlight.api.DestinationAdapter;
import com.ibm.mqlight.api.MalformedDelivery;
import com.ibm.mqlight.api.NonBlockingClient;
import com.ibm.mqlight.api.NonBlockingClientAdapter;
import com.ibm.mqlight.api.QOS;
import com.ibm.mqlight.api.SendOptions;
import com.ibm.mqlight.api.SendOptions.SendOptionsBuilder;
import com.ibm.mqlight.api.StringDelivery;
import com.ibm.mqlight.api.SubscribeOptions;
import com.ibm.mqlight.api.SubscribeOptions.SubscribeOptionsBuilder;
import com.ibm.uk.hursley.perfharness.Config;
import com.ibm.uk.hursley.perfharness.Log;
import com.ibm.uk.hursley.perfharness.amqp.AMQPWorkerThread.AMQPException;
import com.ibm.uk.hursley.perfharness.amqp.utils.FIFO.FIFODelivery;
import com.ibm.uk.hursley.perfharness.amqp.utils.FIFO.FIFOHashMap;
import com.ibm.uk.hursley.perfharness.amqp.utils.MessageContainer.MESSAGE_TYPE;
import com.ibm.uk.hursley.perfharness.util.TypedPropertyException;

				fifoCconnection.put (map);
				Log.logger.info("*** Lost connection with Server ***");
				
				// Report exception to delivery queue which acts as a wake-up
				if (fifoDelivery != null) fifoDelivery.put(amqpException);
			}
			
		}, null);
		
		// Wait for connect complete event.
		if (logEnabled) log("({0}): Create connection - wait on block", amqpAddress);
		HashMap<String,Object> map = fifoCconnection.get();
		
		if (map.containsKey("exception")) {
			if (logEnabled) log("({0}): Create connection - Exception {1}",amqpAddress, map.get("exception").toString());
			client.stop(null, null);
			throw (Exception)map.get("exception");
		}
		
		if (logEnabled) log("({0}): Create connection - completed", amqpAddress);
	}
	

	/**
	 * @param reference
	 * @param topic
	 * @param message
	 * @throws Exception
	 */
	public void sendMessage (final String reference, final String topic, final MessageContainer message) throws Exception {

// Path: AMQPPerfHarness/src/com/ibm/uk/hursley/perfharness/amqp/AMQPWorkerThread.java
// public static class AMQPException extends Exception {
// 	private static final long serialVersionUID = 1L;
// 
// 	/**
// 	 * @param message
// 	 */
// 	public AMQPException(final String message) {
// 		super(message);
// 	}
// 		
// 	/**
// 	 * @param message
// 	 * @param cause
// 	 */
// 	public AMQPException(final String message, final Throwable cause) {
// 		super(message, cause);
// 	}
// }
// 
// Path: AMQPPerfHarness/src/com/ibm/uk/hursley/perfharness/amqp/utils/FIFO.java
// public static class FIFODelivery extends FIFOAbs {
// 	public FIFODelivery(final String reference) {
// 		super(reference);
// 	}
// 
// 	/**
// 	 * Insert an item into the FIFO
// 	 * 
// 	 * @param delivery
// 	 */
// 	public void put(final Delivery delivery) {
// 		super.put(delivery);
// 	}
// 
// 	/**
// 	 * Removes a delivery message from the FIFO
// 	 * 
// 	 * @return a delivery or null if exception.
// 	 * @throws AMQPException 
// 	 *
// 	 */
// 	public Delivery get() throws AMQPException {
// 		Object item = super.get();
// 		if (item instanceof Delivery) {
// 			return (Delivery) item;
// 		}
// 		else {
// 			throw new AMQPException("Internal error: expected Delivery but got " + item.getClass().getName());
// 		}
// 	}
// }
// 
// Path: AMQPPerfHarness/src/com/ibm/uk/hursley/perfharness/amqp/utils/FIFO.java
// public static class FIFOHashMap extends FIFOAbs {
// 	public FIFOHashMap(final String reference) {
// 		super(reference);
// 	}
// 
// 
// 	/**
// 	 * @param hashMap
// 	 */
// 	public void put(final HashMap<String, Object> hashMap) {
// 		super.put(hashMap);
// 	}
// 
// 
// 	/* (non-Javadoc)
// 	 * @see com.ibm.uk.hursley.perfharness.amqp.utils.FIFO.FIFOAbs#get()
// 	 */
// 	@SuppressWarnings("unchecked")
// 	public HashMap<String, Object> get() throws AMQPException {
// 		Object item = super.get();
// 		if (item instanceof HashMap) {
// 			return (HashMap<String, Object>) item;
// 		}
// 		else {
// 			throw new AMQPException("Internal error: expected HashMap but got " + item.getClass().getName());
// 		}
// 	}
// }
// 
// Path: AMQPPerfHarness/src/com/ibm/uk/hursley/perfharness/amqp/utils/MessageContainer.java
// public enum MESSAGE_TYPE {STRING, BYTES};


// Path: AMQPPerfHarness/src/com/ibm/uk/hursley/perfharness/amqp/utils/BlockingJavaClient.java
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.logging.Level;
import com.ibm.mqlight.api.ClientException;
import com.ibm.mqlight.api.ClientOptions;
import com.ibm.mqlight.api.ClientState;
import com.ibm.mqlight.api.CompletionListener;
import com.ibm.mqlight.api.Delivery;
import com.ibm.mqlight.api.DestinationAdapter;
import com.ibm.mqlight.api.MalformedDelivery;
import com.ibm.mqlight.api.NonBlockingClient;
import com.ibm.mqlight.api.NonBlockingClientAdapter;
import com.ibm.mqlight.api.QOS;
import com.ibm.mqlight.api.SendOptions;
import com.ibm.mqlight.api.SendOptions.SendOptionsBuilder;
import com.ibm.mqlight.api.StringDelivery;
import com.ibm.mqlight.api.SubscribeOptions;
import com.ibm.mqlight.api.SubscribeOptions.SubscribeOptionsBuilder;
import com.ibm.uk.hursley.perfharness.Config;
import com.ibm.uk.hursley.perfharness.Log;
import com.ibm.uk.hursley.perfharness.amqp.AMQPWorkerThread.AMQPException;
import com.ibm.uk.hursley.perfharness.amqp.utils.FIFO.FIFODelivery;
import com.ibm.uk.hursley.perfharness.amqp.utils.FIFO.FIFOHashMap;
import com.ibm.uk.hursley.perfharness.amqp.utils.MessageContainer.MESSAGE_TYPE;
import com.ibm.uk.hursley.perfharness.util.TypedPropertyException;

				fifoCconnection.put (map);
				Log.logger.info("*** Lost connection with Server ***");
				
				// Report exception to delivery queue which acts as a wake-up
				if (fifoDelivery != null) fifoDelivery.put(amqpException);
			}
			
		}, null);
		
		// Wait for connect complete event.
		if (logEnabled) log("({0}): Create connection - wait on block", amqpAddress);
		HashMap<String,Object> map = fifoCconnection.get();
		
		if (map.containsKey("exception")) {
			if (logEnabled) log("({0}): Create connection - Exception {1}",amqpAddress, map.get("exception").toString());
			client.stop(null, null);
			throw (Exception)map.get("exception");
		}
		
		if (logEnabled) log("({0}): Create connection - completed", amqpAddress);
	}
	

	/**
	 * @param reference
	 * @param topic
	 * @param message
	 * @throws Exception
	 */
	public void sendMessage (final String reference, final String topic, final MessageContainer message) throws Exception {

		if (message.getMessageType() == MESSAGE_TYPE.STRING) {
