Thursday, August 3, 2017

Benefits of WSO2 ESB

WSO2 Enterprise Service Bus (ESB) is a lightweight, high performance, comprehensive and open source middleware application that enables communication among various heterogeneous systems and business applications. Instead of having to make each of your applications communicate directly with each other in all their various formats, each application simply communicates with the ESB, which handles transforming and routing the messages to their appropriate destinations.

 



Integrating various business systems by creating service and API is just one step away from a xml configuration with WSO2 ESB. You can try out by downloading WSO2 ESB and make your systems integrated.

Some of key benefits of having WSO2 ESB.
  • Enables communication among various heterogeneous applications
  • Uses event-driven and standards-based messaging engine
  • Performs variety of Enterprise Integration Patterns (EIPs)
  • Tooling support for artifact(Service and API) development
  • Message tracing and Analytic capabilities.
  • Mediation debugger capability. 
  • Open Standards (WSDL, SOAP, JMS, HTTP, FTP…)
  • Supports various protocols(HTTP,  HTTPS, JMS, FTP, VFS, ..etc) and Protocol Switch
  • Supports message format transformations
  • Supports message routing 
  • Supports message enrichment
  • Connectors(A ready made tool used to connect to public web APIs) that allow ESB to interact with third party services such as Twitter, Salesforce, Google Docs, JIRA

 Learn more about WSO2 ESB from below
 http://wso2.com/library/articles/2017/07/what-is-wso2-esb



Friday, July 29, 2016

Secure vault support in WSO2 ESB inbound parameters



In ESB 5.0.0, wso2:vault-lookup('alias') expression can be used in all inbound endpoint parameters. even in registry resource text, valut-lookup() expression can be used and set resource as the parameter value.

Parameter value  need to be encrypted and store with a alias and retrieve the actual value in your ESB  inbound configuration as below.

Before adding alias, You need to run the cipher tool in ESB. Go to bin directory and issue
"sh ciphertool.sh -Dconfigure"
Then go to the management console and click on "Manage Password" and create a alias my.username and my.password. here you can store the encrypted value for given values.

Add a registry resource(conf:/userInfo/password) which contains  {wso2:vault-lookup('my.password')} as the text contains.

Then you can use the alias in your inbound parameters with lookup fuction.
 Ex: wso2:vault-lookup('my.password')


<inboundEndpoint xmlns="http://ws.apache.org/ns/synapse"  
          name="activemq"  
          sequence="seq1"  
          onError="fault"  
          protocol="jms"  
          suspend="false">  
   <parameters>  
    <parameter name="interval">10</parameter>  
    <parameter name="sequential">true</parameter>  
    <parameter name="coordination">true</parameter>  
    <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>  
    <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>  
    <parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter>  
    <parameter name="transport.jms.ConnectionFactoryType">queue</parameter>  
    <parameter name="transport.jms.Destination">order</parameter>  
    <parameter name="transport.jms.SessionTransacted">false</parameter>  
    <parameter name="transport.jms.SessionAcknowledgement">AUTO_ACKNOWLEDGE</parameter>  
    <parameter name="transport.jms.CacheLevel">3</parameter>  
    <parameter name="transport.jms.UserName">{wso2:vault-lookup('my.username')}</parameter>  
    <parameter name="transport.jms.Password" key="conf:/userInfo/password"/>  
    <parameter name="transport.jms.SubscriptionDurable">false</parameter>  
    <parameter name="transport.jms.SharedSubscription">false</parameter>  
   </parameters>  
 </inboundEndpoint>  


Monday, July 25, 2016

foreach sample configuration in WSO2 ESB

foreach mediator helps you to iterate through a element array. For a example, if you need to iterate xml array and concatenate them together, bellow configuration read all the id and concatenate them.


 <foreach xmlns:ns1="http://ws.wso2.org/dataservice"  
          id="Idforeach"  
          expression="//ns1:Entries/ns1:Entry/ns1:id">  
       <sequence>  
        <property name="ID"  
             expression="fn:concat($ctx:ID,//ns1:id, ',')"  
             type="STRING"/>  
       </sequence>  
     </foreach>  
     <log level="custom">  
       <property name="IDs" expression="$ctx:ID"/>  
     </log>  
Ex: ESB will log "IDs = 105,106," for below request payload

 <Entries xmlns="http://ws.wso2.org/dataservice">  
 <Entry><id>105</id></Entry>  
 <Entry><id>106</id></Entry>  
 </Entries>



How to secure a queue with username and password in ActiveMQ


How to secure a queue with username and password in ActiveMQ

By Default, Queue in a ActiveMQ server can be access without username and password. Adding below configuration in to activemq.xml will make sure that queue is secure with username and password. Then you need to provide a username and password when you create a connection.



 <broker  
   xmlns="http://activemq.apache.org/schema/core"   
 brokerName="localhost" dataDirectory="${activemq.data}">  
 ...........     
 <plugins>  
     <simpleAuthenticationPlugin>  
       <users>  
         <authenticationUser username="nuwan"   
                   password="mypassword"   
                   groups="admins,publishers,consumers" />  
       </users>  
     </simpleAuthenticationPlugin>  
   </plugins>   
 ................   
  </broker>  



Wednesday, March 11, 2015

Getting Date String from unix time stamp in HIVE Query

if You try to get the Date String from hive query as below, You will get an invalid date.

SELECT timestamp, from_unixtime(timestamp, 'yyyy-MM-dd HH:mm:ss') FROM TableName

1426109700733 > 47161-08-14 00:32:13
 
 from_unixtime expect the time in seconds and you have to use below query to get the date correct.

SELECT timestamp, from_unixtime(CAST(timestamp/1000 as BIGINT), 'yyyy-MM-dd HH:mm:ss') FROM TableName

1426109700733 > 2015-03-11 14:35:00

Thursday, August 7, 2014

How to send a HTTP POST or PUT request with empty content message body into a backend server using WSO2 ESB

How to send a HTTP POST or PUT request with empty content message body into a backend server using WSO2 ESB

By the design, ESB expects a message body to send the request to backend server when the http method is POST or PUT. But you can overwrite this behavior by using the property FORCE_POST_PUT_NOBODY. Then you can post or put the request without message body or with the message body if exist to the backend server.

Bellow is the sample proxy service which capable for sending empty messages

<proxy xmlns="http://ws.apache.org/ns/synapse" name="httpendpoint" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">  
   <target>  
    <inSequence>  
      <log level="full" />  
      <property name="FORCE_POST_PUT_NOBODY" value="true" scope="axis2" type="BOOLEAN" />  
    </inSequence>  
    <outSequence>  
      <send />  
    </outSequence>  
    <endpoint>  
      <http uri-template="http://localhost:8080/echoempty/echoemptyrequest" />  
    </endpoint>  
   </target>  
   <description />  
 </proxy>  

         
Then you can send the http messages as bellow to the proxy service.

POST /services/httpendpoint HTTP/1.1
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
Host: 127.0.0.1:8282
User-Agent: Apache-HttpClient/4.2.3 (java 1.5) 

                     

Monday, July 7, 2014

How to Send a String Parameter to an Axis2 Web Service

If you have written a web service operation which accept a String parameter, You will not be able to pass a string value directly. The below operation is required a string parameter. Then you need to wrap the text inside the CDATA tag. Other wise it will not read the parameter value.

     public void echo(String request)  {
        System.out.println(request);
    }

If you want to send a simple string , You need to wrap it with CDATA. The the output will be >> "Text Content"

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wso2="http://wso2.org">
   <soapenv:Header />
   <soapenv:Body>
      <wso2:echo>
         <!--Optional:-->
         <wso2:request><![CDATA[Text Content]]></wso2:request>
      </wso2:echo>
   </soapenv:Body>
</soapenv:Envelope>
 
If you want to pass a xml content as a string then you have to use CDATA tag as bellow.
Then the output will be >> "<foo>Test</foo>"
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wso2="http://wso2.org">
   <soapenv:Header />
   <soapenv:Body>
      <wso2:echo>
         <!--Optional:-->
         <wso2:request><![CDATA[<foo>Test</foo>]]></wso2:request>
      </wso2:echo>
   </soapenv:Body>
</soapenv:Envelope> 

You need CDATA tag always to send the String value to a web service operation if they have String type parameter