Thursday, 11 July 2013

JAVA COMPUTE NODE CODING & STANDARDS TO CREATE A OUTPUT STRUCTURE FOR AN INPUT XML


import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.*;

public class JavaComputeNodeMsgFlow_JavaCompute extends MbJavaComputeNode {

  public void evaluate(MbMessageAssembly inAssembly) throws MbException {
     MbOutputTerminal out = getOutputTerminal("out");
     MbOutputTerminal alt = getOutputTerminal("alternate");
    
     //Declaration of Variables
     String Ename = null,Location = null,Batch = null,Company = null;

     MbMessage inMessage = inAssembly.getMessage();

     // create new message
     MbMessage outMessage = new MbMessage(inMessage);
     MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly,
             outMessage);
        
 
     //-------- INPUT PARSING ------------  
    
     MbElement InRoot      = inMessage.getRootElement();                // MESSAGE
    
     MbElement InXmlNsc         = InRoot.getLastChild();                   // XMLNSC
    
     MbElement  InDetails  = InXmlNsc.getLastChild();    //<DETAILS></DETAILS>     
                                                                                            
    
     //creating MbElement array to store all employee details
     MbElement Emp[]           = InDetails.getAllElementsByPath("*");        // <EMP></EMP>
    
    
    
     // ------- CREATING STRUCTURE FOR OUTPUT PARSING --------------
    
 
      MbElement OutRoot    = outMessage.getRootElement();          // MESSAGE
    
         MbElement OutXmlNsc       = OutRoot.getLastChild();               // XMLNSC
    
       
     MbElement OutDetails      = OutXmlNsc.createElementAsFirstChild(MbElement.TYPE_NAME,"EMP_DETAILS",null);  //<EMP_DETAILS></EMP_DETAILS>
 
 

   
     //-- This Line used when you have Single <EMP></EMP> Record---
//MbElement OutEmp = OutDetails.createElementAsFirstChild(MbElement.TYPE_NAME,"EMP",null);   
                                                                                                         //<EMP></EMP>
       

   
     //Extracting child elements from <EMP>
    
     for(int i=0;i<Emp.length;i++){
         //-- This Line used when you have Multiple <EMP></EMP> Record---
MbElement OutEmp = OutDetails.createElementAsFirstChild(MbElement.TYPE_NAME,"EMP",null);
                                                                                                           //<EMP></EMP>
        
Ename    = Emp[i].getFirstChild().getValueAsString();
Location  = Emp[i].getFirstChild().getNextSibling().getValueAsString();
Batch       = Emp[i].getFirstChild().getNextSibling().getNextSibling().getValueAsString();
Company = Emp[i].getLastChild().getValueAsString();
        
//Create Values inside Multiple <EMP></EMP> Record ,OutEmp
         OutEmp.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"ENAME",Ename);
         OutEmp.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"LOCATION",Location);
         OutEmp.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"BATCH",Batch);
         OutEmp.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"COMPANY",Company);
          } // End Of For Loop

       
     //Create Values inside Single <EMP></EMP> Record ,OutEmp
 
//OutEmp.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"ENAME",Ename);
     //OutEmp.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"LOCATION",Location);
     //OutEmp.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"BATCH",Batch);
     //OutEmp.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"COMPANY",Company);
 

   
//detach XMLNSC last child because outMessage is created from inMessage and already contains InMessage Structure.
  OutXmlNsc.getLastChild().detach();
    
    
//Finally Propogate the Output to OutAssembly
out.propagate(outAssembly);
    
//clear the output message
 outMessage.clearMessage();   
  }
}

Monday, 8 July 2013

Creation Of new Configurable Service in MQ









Note: mqsisetdbparms command, mqsireload command & mqsicvp commands are mandatory after creating a new configurable service for any in-built nodes.

In the above command console, MIRACLE is a security Identity Name provided in the Configurable service & JdbcProvider is the type you selected while creating the service.

On Another Note :

Viewing and Changing Http Local Listener Ports for HTTP Nodes :

Viewing Existing Http Listener Details :  

mqsireportproperties (BrokerName) - e (ExecutionGroup)  -o HTTPConnector -a

Changing Existing Http Listener Port :  

mqsichangeproperties (BrokerName) -b HTTPListener  -o HTTPConnector -n port -v  7800