Second Run of the AUDOperationsTest.java JUnit for JMS Messaging- IBM JMS Interface Development IBM FileNet 5.5.x Workflow-3


IBM JMS Interface DevelopmentBuilding the AUDOperations.jar, Error Log Location, IBM Certification Exams Second Run of the AUDOperationsTest.java JUnit for JMS Messaging- IBM JMS Interface Development IBM FileNet 5.5.x Workflow-3
0 Comments

// define the name of the QueueManager

//String qManager = “wasadm”;

// and define the name of the Queue

//String qName = “AUDQAR”;

// Put the message to the queue

System.out.println(“Sending a message…”);

// Note that the generic Connection Factory works for both queues & topics

// String cfLookup = “cn=AUDQCF”; //ASB Tests

System.out.println(“Lookup connection factory ” + cfLookup);

// String JNDITopic = “cn=AUDTopic”;

// String JNDIQueue = “cn=AUDQCF”;

// Class variables

javax.jms.Session jmssession = null; // JMS Session

javax.jms.Connection jmsconnection = null; // JMS Connection

//String dLookup = “cn=AUDQCF”; // LDAP JMS Destination

String myMode = null; // Program mode

String destType = null; // Destination type

//JMSDEMO

//MQEnvironment.hostname = “ecmukdemo6”;

//MQEnvironment.channel = “SYSTEM.DEF.CLNT.CONN”;

//MQEnvironment.port = 1417;

MQEnvironment.hostname = hostName;

MQEnvironment.channel = channel;

int MQport = Integer.parseInt(sMQport);

MQEnvironment.port = MQport;

MQEnvironment.properties.put(CMQC.TRANSPORT_PROPERTY, CMQC.TRANSPORT_MQSERIES_CLIENT);

//ASB TODO

//Use two lines of code below for the XML Message

//MQMessage hello_world = new MQMessage();

//hello_world.writeUTF(Message);

// Create a connection to the queue manager

ConnectionFactory connFactory = (ConnectionFactory) ctx.lookup( cfLookup );

ConnectionFactory factory;

Queue queue;

Topic topic;

//Retrieve the Queue object details from the JNDI lookup

queue = (com.ibm.mq.jms.MQQueue)ctx.lookup(JNDIQueue); //ASB Initial code line Changed from (Queue)

System.out.println(“Create and start the connection”);

jmsconnection = connFactory.createConnection(MQuser,MQpassword); //ASB Note that this a server Unix user for MQ not the

// LDAP user!

jmsconnection.start();

//

//ConnectionFactory connFactory = (ConnectionFactory) ctx.lookup( cfLookup );

//JmsConnectionFactory connFactory = (JmsConnectionFactory) ctx.lookup( cfLookup ); //ASB FIX

//

System.out.println(“Create the session”);

//Create the session

boolean transacted = true;

javax.jms.Session session= jmsconnection.createSession(transacted, javax.jms.Session.AUTO_ACKNOWLEDGE);

myDest = (Destination)ctx.lookup(dLookup);

putMsg( myDest, Message,session );

// Clean up session and connection

session.close();

session = null;

jmsconnection.close();

jmsconnection = null;

} catch( JMSException je ) {

System.out.println(“caught JMSException: ” + je);

Exception le = je.getLinkedException();

if (le != null) System.out.println(“linked exception: “+le);

//TODO Log exception message

} catch( Exception e ) {

//TODO Log exception message

System.out.println(“Error : ” + e.getMessage());

System.out.println(“Error Stack : ” + e.toString());

// A finally block is a good place to ensure that we don’t forget

// to close the most important JMS objects

} finally {

if (JMSsession != null) {

//Closing Session

JMSsession.close();

}

if (JMSconnection != null) {

//Closing Connection

JMSconnection.close();

}

}

//if (le.getMessage() != null)

//TODO Add to logger

//Finished

}

}

// A single

private void putMsg( Destination myDest, String outString, javax.jms.Session jmssession )

throws JMSException, Exception

{

//MessageProducer myProducer = JMSsession.createProducer(myDest);//REFLECTION ISSUE!

if (Message.length() > 0) {

TextMessage outMessage = JMSsession.createTextMessage();

//myProducer.send(outMessage); //REFLECTION ISSUE!

JMSsession.commit();

}

myProducer.close();

}

}

Listing 3-9The AUDOperations.java code is updated for rebuild and deployment


Leave a Reply

Your email address will not be published. Required fields are marked *