Thursday, December 29, 2016

Performance Improvement Tip for a BPEL project



Dehydration of runtime instances is a major bottleneck when it comes to the discussion of performance improvement. Depending on the product that is in use, various runtime tables will be involved in persisting the runtime data. This results in having huge volume of data in these tables causing
  • I/O issues
  • Latency in retrieving the records
  • Hard disk space issues and many more
One of the ways is to enable “inMemoryOptimization” property. This is a property in BPEL that can be set to TRUE.
With this setting to True, another property “completionPersistPolicy” is used to determine persistence behaviour.
completionPersistPolicy is having On (Default) / Deferred / Faulted / off. Among this, setting to “faulted” will persist only faulted instances which can be used for recovery and other related tasks.

<property name="bpel.config.inMemoryOptimization">true</property>
<property name="bpel.config.completionPersistPolicy">faulted</property>

Saturday, December 3, 2016

CSV to DVM conversion



There are situations where we get the documents in the CSV (comma separated value) format data to be used in the SOA integration, especially these will be used in XSLT transformations. In these case it required to be converted to  a DVM (Domain Value Map) to get the various values fora  given Key.

Managed to develop a Java program and you can use this for your requirements. In this example input file is "C:\\Work\\sample.csv" output will be "C:\\Work\\output.dvm".

Please use this appropriately

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;


public class DVMCreator {
    private final static Logger logger =
        Logger.getLogger(DVMCreator.class.getName());

    public DVMCreator() {
        super();
    }


    private String inputFile;

    /**
     * @param inputFile
     */
    public void setInputFile(String inputFile) {
        this.inputFile = inputFile;
    }


    /**
     * This method listens for incoming records and handles them as required.
     *
     * @return sheetData
     * @throws Exception
     */
    @SuppressWarnings("finally")
 public List getSheetData() throws Exception {
        List sheetData = new ArrayList();

        FileInputStream fis = null;
        try {
         System.out.println(inputFile);
            fis = new FileInputStream(inputFile);
            ArrayList<String> list = null;
            
         //Construct BufferedReader from InputStreamReader
         BufferedReader br = new BufferedReader(new InputStreamReader(fis));
         
         String line = null;
         while ((line = br.readLine()) != null) {
           list = new ArrayList(Arrays.asList(line.split("\\s*,\\s*")));
           sheetData.add(list);
         }
         br.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fis != null) {
                fis.close();
            }
            return sheetData;
        }
    }


     private static String convertExcelToDVMData(List sheetData,String dvmName ) {
        StringBuffer xmlData = new StringBuffer();
      
      dvmName = dvmName.replaceAll(".dvm", "");
        
        Map map = new HashMap();
        xmlData.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
        xmlData.append("<dvm name=\"");
        xmlData.append(dvmName);
        xmlData.append("\"");
        xmlData.append(" xmlns=\"http://xmlns.oracle.com/dvm\">");
        xmlData.append("\n");

        xmlData.append("<description></description>");
        xmlData.append("\n");

        xmlData.append("<columns>");
        xmlData.append("\n");


        List columnNamelist = (List)sheetData.get(0);
        for (int j = 0; j < columnNamelist.size(); j++) {
            xmlData.append("<column name=\"");
            xmlData.append(columnNamelist.get(j));
            xmlData.append("\"/>");
            xmlData.append("\n");

        }
//        logger.log(Level.INFO, "");
        xmlData.append("</columns>");

        xmlData.append("\n");

        xmlData.append("<rows>");
        xmlData.append("\n");

        for (int i = 1; i < sheetData.size(); i++) {
            xmlData.append("<row>");
            xmlData.append("\n");

            List list = (List)sheetData.get(i);
            for (int j = 0; j < list.size(); j++) {
                xmlData.append("\t");

                xmlData.append("<cell>");
                xmlData.append(list.get(j));
                xmlData.append("</cell>");
                xmlData.append("\n");

                if (j < list.size() - 1) {
                    logger.log(Level.INFO, ", ");
                }
            }
//            logger.log(Level.INFO, "");
            xmlData.append("</row>");
            xmlData.append("\n");
        }
        xmlData.append("</rows>");
        xmlData.append("</dvm>");

        return xmlData.toString();
    }
  

  public static boolean writeDVM(String xmlData, File file) throws Exception {
      try {
          FileOutputStream fOut = new FileOutputStream(file);
          fOut.write(xmlData.getBytes());
          fOut.flush();
          fOut.close();
          logger.log(Level.INFO, "File Created .::" + file.getName());

      } catch (Exception e) {
          logger.log(Level.INFO,
                     "Create() failed : " + e.getMessage());
          throw e;
      }
      return true;
  }
  
  
    /**
     * main method
     *
     * @param args      Expect one argument that is the file to read.
     * @throws IOException  When there is an error processing the file.
     */
    public static void main(String[] args) throws IOException {
        DVMCreator reader = new DVMCreator ();
        String spliter[] = null;
        String inputXL = null;
        String outputDVM = null;
         
                reader.setInputFile("C:\\Work\\sample.csv");
                File file = null;
              try {
                  file = new File("C:\\Work\\output.dvm");
//                  logger.log(Level.INFO, "File Created .::" + outputDVM);

              } catch (Exception e) {
                  logger.log(Level.INFO,
                             "Create() failed : " + e.getMessage());
              }

                try {
                    List data = reader.getSheetData();
                    
                    String xmlData = convertExcelToDVMData(data,file.getName());
                    boolean flag = writeDVM(xmlData, file);
//                    logger.log(Level.INFO, "XML data ::" + xmlData);


                } catch (Exception e) {
                    logger.log(Level.INFO, "Error occured" + e.getMessage());
                    e.printStackTrace();
                }
                logger.log(Level.INFO, "DVM  write done.");
        
    }
}

Friday, December 2, 2016

Oracle SOA : JMS :How to read the contents of JMSFileStore ?



This article explains about how to read the contents of JMSFileStore in Oracle SOA environment

Generally JMSFileStore is the repository for storing the persistant JMS messages in filesystem. This is generally located in the %DOMEIN_HOME% of Oracle SOA installation. The content of the file is not a human readable one. However, at times, these JMSFileStore gets corrupted and hence will not be able to start the sever. This would lead to check the contents of JMSFileStore.

Here below are the steps that can be followed.


  1. Set the environment variables by executing the command  – setWLSEnv (C:\Oracle\Middleware12c\Oracle_Home\wlserver\server\bin)
  2. Navigate to the location of the JMSFileStore file. Generally it will be in  %DOMEIN_HOME% (C:\Oracle\Middleware12c\Oracle_Home\user_projects\domains\soa_domain\SOAJMSFileStore)
  3. Run the command – java weblogic.store.Admin
  4. Just try to list the JMSFileStore files ( e.g :list -dir .)
  5. Use the filename from the output of above command to open the JMSFileStore (openfile -store SOAJMSFILESTORE -dir .)
  6. Once the file is opened, execute the command to dump the content into an XML File (dump -store SOAJMSFILESTORE -out a.xml -conn -deep)
  7. Here you go !!!!…… Open the XML file to see the content of JMSFileStore


Below screenshot explains the steps in practice !!!