jeudi 30 octobre 2014

Dummy TIBCO queue for testing


Vote count:

0




I have written a piece of code to connect to TIBCO queue and fetch customer data. But I cannot find a way to test it before moving it to production. Can we create a dummy queue somehow so that I can ensure that my program is functional before packaging it for production?


Here is my code..



package GI;

import javax.jms.JMSSecurityException;
import javax.naming.InitialContext;

import javax.jms.Queue;
import javax.jms.TextMessage;
import javax.jms.QueueSender;
import javax.jms.DeliveryMode;
import javax.jms.QueueSession;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;

public class Queue
{
public Queue()
{
System.err.println("\n------------------------------------------------------------------------");
System.err.println("tibjmsTEQueue SAMPLE");
System.err.println("------------------------------------------------------------------------");
}

public String QueueProcess(String XMLRequest, String serverUrl, String userName, String password, String InQueueName)
{
String [] args = new String[4];

args[0]=serverUrl;
args[1]=userName;
args[2]=password;
args[3]=InQueueName;

System.out.println("Server....................... "+serverUrl);
System.out.println("User......................... "+userName);
System.out.println("InQueue...................... "+InQueueName);
System.out.println("------------------------------------------------------------------------\n");

try
{
tibjmsUtilities.initSSLParams(serverUrl,args);
}
catch (JMSSecurityException e)
{
System.err.println("JMSSecurityException: "+e.getMessage()+", provider="+e.getErrorCode());
e.printStackTrace();
System.exit(0);
}

System.err.println("Starting");

QueueConnection connectionIn = null;
try
{
InitialContext context = new InitialContext();

Queue tibcoQueue = (Queue) context.lookup("queue/queue0");

QueueConnectionFactory factory = new com.tibco.tibjms.TibjmsQueueConnectionFactory(serverUrl);
connectionIn = factory.createQueueConnection(userName, password);
QueueSession sessionIn = connectionIn.createQueueSession(false,javax.jms.Session.AUTO_ACKNOWLEDGE);

QueueSender queueSender = sessionIn.createSender(tibcoQueue);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

QueueReceiver queueReceiver = sessionIn.createReceiver(tibcoQueue);

connectionIn.start();

System.out.println("Connected to Queue...");
System.out.println("XMLRequest: " + XMLRequest);

TextMessage sendXMLRequest = sessionIn.createTextMessage(XMLRequest);

queueSender.send(sendXMLRequest);

System.out.println("sent: " + sendXMLRequest.getText());

TextMessage XMLResponse = (TextMessage) queueReceiver.receive();

System.out.println("received: " + XMLResponse.getText());
return((String) XMLResponse.getText());
}
catch(Exception e)
{
System.err.println("Exitting with Error");
e.printStackTrace();
System.exit(0);
}
finally
{
System.err.println("Exitting");
try {connectionIn.close();}
catch(Exception e1) {}
}

return("Failure");
}

public static void main(String args[])
{
Queue t = new Queue();
}
}


asked 1 min ago







Dummy TIBCO queue for testing

Aucun commentaire:

Enregistrer un commentaire