import java.io.*;
import java.util.*;
import com.ibm.mq.*;
public class Actions
{
private MQQueueManager myQueueManager;
private MQPutMessageOptions myPutMsgOptions;
private MQQueue myQueue;
private String xmlStr = null;
private String finalFileName = null;
private String xmlDocument = null;
private String Formatted_msg = null;
public int init() throws Throwable {
try {
MQEnvironment.hostname = "CPLIQPDE.homepot.com";
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES_CLIENT);
MQEnvironment.channel = "SYSTEM.ADMIN.SVRCONN";
MQEnvironment.port = 17800;
myQueueManager = new MQQueueManager("QM0.QA.US.CPLIQPDE");
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE | MQC.MQOO_FAIL_IF_QUIESCING;
myQueue = myQueueManager.accessQueue("MM.PO.SCV.APV.IO", openOptions, null, null, null);
myPutMsgOptions = new MQPutMessageOptions();
myPutMsgOptions.options = MQC.MQPMO_NONE;
} catch (Exception e) {
System.out.println(e);
}
return 0;
}//end of init
public int action() throws Throwable {
try {
MQMessage myPutMessage = new MQMessage();
myPutMessage.clearMessage();
myPutMessage.persistence = MQC.MQPER_PERSISTENT;
myPutMessage.correlationId = MQC.MQCI_NONE;
myPutMessage.messageId = MQC.MQMI_NONE;
FileReader fr = null;
File f=new File("IO_3.xml");
int fileLength = (int) f.length();
char[] cbuf = new char[fileLength];
try {
fr = new FileReader(f);
fr.read(cbuf);
} catch (FileNotFoundException e) {
lr.error_message("Could not find data file: " + f);
lr.abort();
} catch (IOException e) {
lr.error_message("Error reading file: " + f);
lr.abort();
} finally{
try{
if(fr!=null){
fr.close();
}
}catch(IOException ioe){
lr.error_message("Error closing file reader: " + ioe);
lr.abort();
}
}
new String(cbuf);
String xmlDocument = String.valueOf(cbuf);
xmlDocument = xmlDocument.replace("<orderNumber>1268246824</orderNumber>","<orderNumber><pOrderNo></orderNumber>");
xmlDocument = xmlDocument.replace("<skuNumber>100013</skuNumber>","<skuNumber><pSkuNo></skuNumber>");
xmlDocument = xmlDocument.replace("<receivingLocationNumber>6158</receivingLocationNumber>","<receivingLocationNumber><pRecvLocNo></receivingLocationNumber>");
Formatted_msg = xmlDocument;
myPutMessage.writeString(Formatted_msg);
// System.out.println("Formatted_msg:\n" +Formatted_msg);
// System.out.println("myPutMessage:\n" +myPutMessage);
myQueue.put(myPutMessage, myPutMsgOptions);
} catch (Exception e) {
System.out.println(e);
}
return 0;
}//end of action
public int end() throws Throwable {
try {
myQueue.close();
myQueueManager.disconnect();
} catch (Exception e ) {
System.out.println(e);
}
return 0;
}//end of end
}
No comments:
Post a Comment