Wednesday, March 22, 2017

Taledn Open Studio - How to use tMap to output all records in one table but not exist in the other table?

This is the example about how to use tMap component in Talend to extract all records in one table but not in the other table.



DB1 has 12 records, there is one record whose key has existed in db2 table. So I would like to have only new records not in db2 table should output to db_output.

Let's look at the tMap setup. DB1 is main input (row1), db2 is the lookup (row2). In the lookup, choose Inner job. In the output choose Catch lookup inner join reject = true.



Tuesday, November 1, 2016

Log4J - log file name with date (each day have one log file)

This is the log4j.properties file I used.

 log4j.rootCategory=INFO, console, file  
 log4j.appender.console=org.apache.log4j.ConsoleAppender  
 log4j.appender.console.layout=org.apache.log4j.PatternLayout  
 log4j.appender.console.layout.ConversionPattern=%d{dd MMM yy HH:mm:ss} %c{1} %-5p %x - %m%n  
 
 log4j.appender.file=org.apache.log4j.DailyRollingFileAppender  
 log4j.appender.file.File=/msgs/logs/project.log  
 log4j.appender.file.File.DatePattern='.'yyyy-MM-dd  
 log4j.appender.file.layout=org.apache.log4j.PatternLayout  
 log4j.appender.file.layout.ConversionPattern=%d{dd-MM-yyyy HH:mm:ss} %-5p %c{1}:%L - %m%n  

Wednesday, June 29, 2016

Jquery - disable the default action, reload datatables, and others


When I worked on a form submit, I would like to use the js code to submit the form. But I found out  it submitted twice. Then I realized I need to disable the default action from the form.

Also after finished the action, I would like the data table to be reloaded again. The code is as below.


     $("button").click(function(e)  
     {  
       e.preventDefault(); // default form action of the event will not be triggered  
       var data = {  
         'id[]' : []  
       };  
       $.each($("input[name='id[]']:checked"), function()  
       {  
         data['id[]'].push($(this).val());  
       });  
       $.ajax({  
         url : contextPath  
           + "/reloadTranscepta", type : "POST", dataType : "json", data : data, success : function(data)  
         {  
           table.ajax.reload(null, false); // Reload the table  
           $('#transcepta-select-all').prop('checked', false);  
           if (data.status == '200 OK')  
           {  
             $("#result").html('<strong>Success!</strong> The POs you selected have been sent successfully.');  
             $("#result").attr('class', 'alert alert-success');  
           }  
           else  
           {  
             $("#result").html('<strong>Error!</strong> A problem has been occurred while sending POs to Transcepta.');  
             $("#result").attr('class', 'alert alert-danger alert-error');  
           }  
         }, error : function(xhr, textStatus, errorThrown)  
         {  
           $("#result").html('<strong>Error!</strong> A problem has been occurred while sending POs to Transcepta.');  
           $("#result").attr('class', 'alert alert-danger alert-error');  
         }  
       });  
     });  

Wednesday, April 13, 2016

DB2 Table Reorg - DB2 SQL Error: SQLCODE=-668, SQLSTATE=57016, SQLERRMC=7;

I got db2 error message when I ran a web application.

 DB2 SQL Error: SQLCODE=-668, SQLSTATE=57016, SQLERRMC=7;   

After doing some research, I found out I need to reorg the table it mentioned in the error message.

I tried to just run the reorg command in Aqua Data Studio, but I got error message. After consulted with our DBA, this reorg command is not a sql command. The way to run it in Aqua Data studio is as below.

 call sysproc.admin_cmd('reorg table TABLE_NAME')  

Tuesday, March 15, 2016

How to change an existing Java application to dynamic web application in Eclipse and deploy it to tomcat server?

I have an old application to enhance and want to convert it into dynamic web application in Eclipse.

1. Open the java application in eclipse. Right click on the project name, and then choose "properties".




2. Choose Project Facets on the left side. On the right side, check "Dynamic Web Module" and "Java" box. Then click OK button.



3. Now this project is a dynamic web project.

4. Deploy the application to local tomcat server. Go to properties again as step 1.

Choose Deployment Assembly on the left side, then in the right side, add the real source directory and deploy path. Then click ok.


5. Add web module into tomcat 8 server.
Right click the Tomcat server and choose Add and Remove, the in the pop up window, add left side application to the right side. Now we can restart tomcat server, the new application will be deployed to the server side and run.



Thursday, March 3, 2016

WSO2 ESB ERROR - ClientUtils The system cannot infer the transport information

After I tested my proxy service in ESB, I got the following error when it tried to save the message into a file.

ERROR - ClientUtils The system cannot infer the transport information from the vfs:file:///C:/Temp URL.  

The source code I am using is as below:

 <?xml version="1.0" encoding="UTF-8"?>  
 <sequence name="saveToFS" trace="disable" xmlns="http://ws.apache.org/ns/synapse">  
  <property  
   expression="fn:concat(get-property('SYSTEM_DATE', 'yyMMddHHmmss'), '-', get-property('filename'), '.xml')"  
   name="transport.vfs.ReplyFileName" scope="transport" type="STRING"/>  
  <property name="OUT_ONLY" scope="default" type="STRING" value="true"/>  
  <call>  
   <endpoint>  
    <address trace="disable" uri="vfs:file:///c:/Temp"/>  
   </endpoint>  
  </call>  
  <log level="custom">  
   <property name="msg" value="File Saved to Disk"/>  
  </log>  
 </sequence>  

After research, I found the error is I need to enable vfs transport in the configuration file.
I enabled the following lines in wso2esb-4.9.0\repository\conf\axis2\axis.xml file. Then it works.

  <transportReceiver name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportListener"/>  
 ......  
 <transportSender name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportSender"/>  

Tuesday, February 23, 2016

Understanding WSO2 ESB Architecture from a Messaging Perspective


I found this diagram from http://supunk.blogspot.com/2009/07/wso2-esb-high-level-architectural.html?view=sidebar. It is very helpful for me to understand how messages work inside ESB.


An application sends a message to the ESB.
The message is picked up by the ESB transport.
Transport sends the message through a message pipe. Quality of service aspects like Security and reliable messaging of the message is taken care in this pipe. Internally this pipe is the in-flow and out-flow of Axis2. ESB can operate in two modes. Message mediation or proxy services. In case of message mediation a single pipe is used. In case of proxy services we can think of separate pipes connecting transport to different proxy services.
Message transformation + routing can be seen as a single unit. As the diagram specifies there is no clear separation between message transformation components and routing components. WSO2 ESB call this the mediation framework. Some transformations happens before routing decision has taken. Some transformations happens after the the routing decision has taken. This part is the Synapse implementation.
After this message is injected to the separate pipes depending on the destinations. Here again quality of service aspects of the messages is determined.
At the end there is a transport layer. This transport layer takes care of the transport protocol transformations required by the ESB.