// Path: JMSPerfHarness/src/com/ibm/uk/hursley/perfharness/jms/DestinationWrapper.java
// public final class DestinationWrapper<E extends Destination> {
// 	
// 	public E destination;
// 	public String name;
// 	
// 	public DestinationWrapper( String name, E destination ) {
// 		this.destination = destination;
// 		this.name = name;
// 	}
// 	
// }


import java.util.logging.Level;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.Queue;
import com.ibm.uk.hursley.perfharness.Config;
import com.ibm.uk.hursley.perfharness.Log;
import com.ibm.uk.hursley.perfharness.WorkerThread;
import com.ibm.uk.hursley.perfharness.jms.DestinationWrapper;
/********************************************************* {COPYRIGHT-TOP} ***
* Licensed Materials - Property of IBM
*
* IBM Performance Harness for Java Message Service
*
* (C) Copyright IBM Corp. 2005, 2007  All Rights Reserved.
*
* US Government Users Restricted Rights - Use, duplication, or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
********************************************************** {COPYRIGHT-END} **/
/*
 * $Id: Responder.java 556 2013-09-27 15:17:24Z smassey $
 * JMSPerfHarness $Name$
 */

package com.ibm.uk.hursley.perfharness.jms.r20;




/**
 * Takes messages off the request queue and places the same message on the reply queue.
 * Does not currently have an option to change the CorrelationId (in keeping with the
 * Requestor class).
 * @author smassey@uk.ibm.com 
 */
public final class Responder extends JMS20WorkerThread implements WorkerThread.Paceable {

	@SuppressWarnings("unused")
	private static final String c = com.ibm.uk.hursley.perfharness.Copyright.COPYRIGHT; // IGNORE compiler warning

    Message inMessage = null;
    Message outMessage = null;
	
    //Use temporary reply queues
	private final boolean tempQueues = Config.parms.getString("oq").length() == 0;
	
	//Use input message for output message, else crete new output message
	private final boolean copyReplyFromRequest = Config.parms.getBoolean("cr");
	
	//This is horrible using the same flag as requestor to mean different behaviour in the responder
	// -co requester - Use correlationID scheme
	// -co responder - Copy MsgID from input message to CorrelationID if set, else copy CorrelationID from input message
	private final boolean correlIDFromMsgID = Config.parms.getBoolean("co");
	
	//Use fixed reply queues, avoids extraction of replyTo and costly destination comparison
    private final boolean fixedReplyQ = Config.parms.getBoolean("jfq");
    
	public static void registerConfig() {
		Config.registerSelf(Responder.class);
	}    
    
    /**
     * Constructor for JMSClientThread.
     * @param name
     */
    public Responder(String name) {
    	super(name);
    }

    protected void buildJMSResources() throws Exception {
    	super.buildJMSResources();
    	
        // Get destination pair if multiple are configured.
        int destID = destFactory.generateDestinationID(getThreadNum());
        String iq = Config.parms.getString("iq");
        String oq = Config.parms.getString("oq");
        if (destID >= 0) {
        	iq += String.valueOf(destID);
        	oq += String.valueOf(destID);
        }
        
// Path: JMSPerfHarness/src/com/ibm/uk/hursley/perfharness/jms/DestinationWrapper.java
// public final class DestinationWrapper<E extends Destination> {
// 	
// 	public E destination;
// 	public String name;
// 	
// 	public DestinationWrapper( String name, E destination ) {
// 		this.destination = destination;
// 		this.name = name;
// 	}
// 	
// }


// Path: JMSPerfHarness/src/com/ibm/uk/hursley/perfharness/jms/r20/Responder.java
import java.util.logging.Level;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.Queue;
import com.ibm.uk.hursley.perfharness.Config;
import com.ibm.uk.hursley.perfharness.Log;
import com.ibm.uk.hursley.perfharness.WorkerThread;
import com.ibm.uk.hursley.perfharness.jms.DestinationWrapper;

/********************************************************* {COPYRIGHT-TOP} ***
* Licensed Materials - Property of IBM
*
* IBM Performance Harness for Java Message Service
*
* (C) Copyright IBM Corp. 2005, 2007  All Rights Reserved.
*
* US Government Users Restricted Rights - Use, duplication, or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
********************************************************** {COPYRIGHT-END} **/
/*
 * $Id: Responder.java 556 2013-09-27 15:17:24Z smassey $
 * JMSPerfHarness $Name$
 */

package com.ibm.uk.hursley.perfharness.jms.r20;




/**
 * Takes messages off the request queue and places the same message on the reply queue.
 * Does not currently have an option to change the CorrelationId (in keeping with the
 * Requestor class).
 * @author smassey@uk.ibm.com 
 */
public final class Responder extends JMS20WorkerThread implements WorkerThread.Paceable {

	@SuppressWarnings("unused")
	private static final String c = com.ibm.uk.hursley.perfharness.Copyright.COPYRIGHT; // IGNORE compiler warning

    Message inMessage = null;
    Message outMessage = null;
	
    //Use temporary reply queues
	private final boolean tempQueues = Config.parms.getString("oq").length() == 0;
	
	//Use input message for output message, else crete new output message
	private final boolean copyReplyFromRequest = Config.parms.getBoolean("cr");
	
	//This is horrible using the same flag as requestor to mean different behaviour in the responder
	// -co requester - Use correlationID scheme
	// -co responder - Copy MsgID from input message to CorrelationID if set, else copy CorrelationID from input message
	private final boolean correlIDFromMsgID = Config.parms.getBoolean("co");
	
	//Use fixed reply queues, avoids extraction of replyTo and costly destination comparison
    private final boolean fixedReplyQ = Config.parms.getBoolean("jfq");
    
	public static void registerConfig() {
		Config.registerSelf(Responder.class);
	}    
    
    /**
     * Constructor for JMSClientThread.
     * @param name
     */
    public Responder(String name) {
    	super(name);
    }

    protected void buildJMSResources() throws Exception {
    	super.buildJMSResources();
    	
        // Get destination pair if multiple are configured.
        int destID = destFactory.generateDestinationID(getThreadNum());
        String iq = Config.parms.getString("iq");
        String oq = Config.parms.getString("oq");
        if (destID >= 0) {
        	iq += String.valueOf(destID);
        	oq += String.valueOf(destID);
        }
        
    	DestinationWrapper<Queue> consumerDestinationWrapper = jmsProvider.lookupQueue(iq, context);