// 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;

/********************************************************* {COPYRIGHT-TOP} ***
* Copyright 2016 IBM Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the MIT License
* which accompanies this distribution, and is available at
* http://opensource.org/licenses/MIT
********************************************************** {COPYRIGHT-END} **/
package com.ibm.uk.hursley.perfharness.amqp.utils;



/**
 * @author ElliotGregory
 *
 */
public class BlockingJavaClient {
	
	private final static Boolean logEnabled = Log.logger.getLevel().intValue() <= Level.FINE.intValue();
	
	private final static int QUEUE_SIZE_WARNING = 20;
	
	/** AMQP Client object **/
	private final NonBlockingClient client;
	/** Server address **/
	private final String amqpAddress;
	/** FIFO communication **/

// 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;

/********************************************************* {COPYRIGHT-TOP} ***
* Copyright 2016 IBM Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the MIT License
* which accompanies this distribution, and is available at
* http://opensource.org/licenses/MIT
********************************************************** {COPYRIGHT-END} **/
package com.ibm.uk.hursley.perfharness.amqp.utils;



/**
 * @author ElliotGregory
 *
 */
public class BlockingJavaClient {
	
	private final static Boolean logEnabled = Log.logger.getLevel().intValue() <= Level.FINE.intValue();
	
	private final static int QUEUE_SIZE_WARNING = 20;
	
	/** AMQP Client object **/
	private final NonBlockingClient client;
	/** Server address **/
	private final String amqpAddress;
	/** FIFO communication **/

	private final FIFODelivery fifoDelivery;
