Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8533

Re: Adapter Development for Dynamic EOIO Queue

$
0
0

Hi Dheeraj,

 

Yes you're right. I misunderstood that its a field. Based on the input xml you provided, i understand that you need to get the dynamic queue name in child element.

 

For your parameter: /YPSP6/IDOC/YP6PROJ/PSPID, you need to code to get value based on the xpath like below.

 

XPath xPath =  XPathFactory.newInstance().newXPath();

NodeList nodeList = (NodeList) xPath.compile("/YPSP6/IDOC/YP6PROJ/PSPID").evaluate(doc, XPathConstants.NODESET);

 

Please use below code and test, it works for me.

Code:

public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)

  throws ModuleException {

 

  try {

  String param1 = (String) moduleContext.getContextData("param1");

  //String param2 = (String) moduleContext.getContextData("param2");

 

 

 

  Message msg = (Message) inputModuleData.getPrincipalData();

  Payload payload = msg.getDocument();

 

  InputStream inps = (InputStream) payload.getInputStream();

 

  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

  DocumentBuilder db = dbf.newDocumentBuilder();

  Document doc = db.parse(inps);

  doc.getDocumentElement().normalize();

 

  XPath xPath =  XPathFactory.newInstance().newXPath();

  NodeList nodeList = (NodeList) xPath.compile(param1).evaluate(doc, XPathConstants.NODESET);

 

  //NodeList nodeLst1 = doc.getElementsByTagName(param1);

  //NodeList nodeLst2 = doc.getElementsByTagName(param2);

 

  //Element Elmnt1 = (Element) nodeLst1.item(0);

 

  //NodeList ndLst1 = Elmnt1.getChildNodes();

 

  String queueId;

 

  if (nodeList.item(0) != null)

       queueId =nodeList.item(0).getFirstChild().getNodeValue();

  else

       queueId = msg.getSequenceId();

 

  msg.setSequenceId(queueId);

 

 

 

  inputModuleData.setPrincipalData(msg);

 

  return inputModuleData;

  }

 

  catch (Exception e) {

  e.printStackTrace();

  ModuleException me = new ModuleException("Unable to create Queue", e);

  throw me;

  }

 

  }

 

Sender Channel:

Channel.PNG

 

Input XML:

<?xml version="1.0" encoding="utf-8" ?>

  <YPSP6><IDOC BEGIN="1"><YP6PROJ SEGMENT="1"><PSPID>SP-35677</PSPID></YP6PROJ></IDOC></YPSP6>

 

Message in Sxmb_Moni:

Message.PNG

 

Thanks

 

Regards,

Praveen


Viewing all articles
Browse latest Browse all 8533

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>