Pages

Friday, August 4, 2017

Powerful capabilities of WSO2 ESB

WSO2 enterprise service bus


WSO2 Enterprise Service Bus is the leading ESB solutions in the market which is 100% free and open source with commercial support. It is a battle tested Enterprise Service Bus catering for all enterprise integration needs. With its new release, we have taken the capabilities of WSO2 Enterprise Service Bus (WSO2 ESB) to a new level.

The WSO2 ESB is now more powerful than ever before, catering 360 degrees of seamless Enterprise Integration requirements with capabilities of integrating legacy systems to cutting edge systems.

WSO2 ESB is like as "swiss army knife" for system integration. With the new release of WSO2 ESB, it's more powerful than ever.

In this post I would like to list some powerful capabilities of WSO2 ESB:

  1. WSO2 ESB now comes with 
    • Built in Data services server ( DSS ) exposing your data stores as Services and APIs.
    • Business Process Server (BPS) to cater for business-processes / workflows (BPEL, BPMN) and human interactions (WS-Humantask) with Business Process Profile 
    • Message Broker (MB)  catering fully pledged messaging capabilities including JMS 1.1 and JMS 2.0 for enterprise messaging with Message Broker profile
    • Integration Analytics message tracing and analytics support with analytics profile
  2. One of the best performing open sources ESB's in the market.
  3. A mature product and supports all enterprise integration patterns.
  4. Complete feature set to cater for any integration need.
  5. Eclipse based IDE support to quickly develop, debug, package, deploy your integration flows.
  6. Consultancy / Support and Services are readily available from WSO2 and WSO2 Partners world wide.


For more interesting information on WSO2 ESB, read through this comprehensive article written by Samisa Abeysinghe (Chief Engineering and Delivery Officer - WSO2 ) on What is WSO2 ESB.

http://wso2.com/library/articles/2017/07/what-is-wso2-esb/

This article explains about when you should consider using WSO2 ESB, what are the advantages of it and also about the powerful capabilities of WSO2 ESB.

Download and play with it now ... ENJOY !!

Thanks,
Mili

Saturday, July 22, 2017

Setting up SMB file share in fresh Windows Server 2012-R2


Open "Server Manager" and Navigate to File and Storage Services > Volumes



In Volumes view, you can find SHARES section, click on "Start the Add Roles and Features Wizard" for feature installation wizard.

Under Server Roles tab, select "File and iSCSI Services" as shown below and click Next.




Click Next to reach Confirmation tab, which will list down installed server roles as follows. Click Install to install them.


Click Close to complete the installation.



Now, create SMB share. Navigate to File and Storage Services > Volumes
Then click New Share to start New Share Wizard under TASKS in SHARES section.




Select the "SMB Share - Quick" as file share profile and click Next




Browse to the directory shared or Select relevant volume in Share Location tab. Then click Next



Provide Share Name and click Next



Keep default settings in Other settings tab, if not needed, and click Next to navigate to Permissions tab.
Click Customize Permissions 


In Advanced Security settings view, under Share tab, you can find permission entries. By default, it contains Read-only rights for everyone. 
Here, I'm adding permission entry to provide full-control (RW) to Administrator user. To perform that click Add to add new permission entry.



 Click Select a principal in Permission Entry view


Provide User name or group name under "Enter the object name to select" text box. Here I'm providing Administrator (user name) and click OK


Then select relevant permission level under Permissions section and click OK


Newly added permission entry will list down as follows.


Click OK and click Next to Confirm changes and complete New Share wizard


After closing the wizard, newly created SMB file share will be listed under Share tab as follows



Now you can access SMB share from a remote machine within the network with URI smb://[Host/IP]/[Share_Name]. eg: smb://192.168.58.5/SMB_SHARE 

ENJOY FILE SHARING !!

Thanks,
Mili





Tuesday, June 6, 2017

How to solve Optimistic locking error if you get with WSO2 BPS with Oracle combination

There is possibility to get transaction warning optimistic locking error as shown below

[BPELServer-3] [2016-03-29 06:45:41,125]  WARN {Transaction} -  Unexpected exception from beforeCompletion; transaction will roll back
org.apache.openjpa.persistence.OptimisticLockException: Optimistic locking errors were detected when flushing to the data store.  The following objects may have been concurrently modified in another transaction: [org.apache.ode.dao.jpa.MessageDAOImpl@21dae500, org.apache.ode.dao.jpa.MessageDAOImpl@45fcaea2, org.apache.ode.dao.jpa.MessageDAOImpl@497908f1, org.apache.ode.dao.jpa.MessageDAOImpl@47bbc1bc, org.apache.ode.dao.jpa.MessageDAOImpl@6334d00f, org.apache.ode.dao.jpa.MessageDAOImpl@39c2059, org.apache.ode.dao.jpa.MessageDAOImpl@773f167b, org.apache.ode.dao.jpa.MessageDAOImpl@6eeda72e]
at org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2326)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2174)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2072)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1843)
at org.apache.openjpa.kernel.DelegatingBroker.flush(DelegatingBroker.java:1045)
at org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:663)
at org.apache.ode.dao.jpa.ProcessInstanceDAOImpl.delete(ProcessInstanceDAOImpl.java:227)
at org.apache.ode.bpel.engine.BpelRuntimeContextImpl$2.beforeCompletion(BpelRuntimeContextImpl.java:254)
at org.apache.ode.scheduler.simple.SimpleScheduler$2.beforeCompletion(SimpleScheduler.java:340)
at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:498)
at org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:238)
at org.apache.ode.scheduler.simple.SimpleScheduler.execTransaction(SimpleScheduler.java:298)
at org.apache.ode.scheduler.simple.SimpleScheduler.execTransaction(SimpleScheduler.java:246)
at org.apache.ode.scheduler.simple.SimpleScheduler$RunJob.call(SimpleScheduler.java:541)
at org.apache.ode.scheduler.simple.SimpleScheduler$RunJob.call(SimpleScheduler.java:525)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.openjpa.persistence.OptimisticLockException: An optimistic lock violation was detected when flushing object instance "org.apache.ode.dao.jpa.MessageDAOImpl@21dae500" to the data store.  This indicates that the object was concurrently modified in another transaction.
FailedObject: org.apache.ode.dao.jpa.MessageDAOImpl@21dae500
at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.checkUpdateCount(BatchingPreparedStatementManagerImpl.java:303)
at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:186)
at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.batchOrExecuteRow(BatchingPreparedStatementManagerImpl.java:104)
at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:83)
at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:99)
at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:87)
at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:550)
at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:106)
at org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:103)
at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:713)
at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
... 21 more
....................

[BPELServer-3] [2016-03-29 06:45:41,148] DEBUG {org.apache.ode.bpel.engine.InstanceLockManager} -  Thread[BPELServer-3,5,main]: unlock(iid=253)
[BPELServer-3] [2016-03-29 06:45:41,149] DEBUG {org.apache.ode.bpel.engine.MyRoleMessageExchangeImpl} -  Received myrole mex response callback
[BPELServer-3] [2016-03-29 06:45:41,149]  WARN {org.apache.ode.bpel.engine.MyRoleMessageExchangeImpl} -  Transaction is rolled back on sending back the response.


This occurs with OpenJPA + Oracle combination (This occurred to me with Oracle 11g). According to [1] OpenJPA performs some statements as batches which may fail in several cases.

[1] https://wso2.org/jira/browse/CARBON-7500

Monday, May 16, 2016

JSON variable ussage within BPMN processes in WSO2 BPS v3.5.0 and v3.5.1

ATM Activiti provides JSON as a data type.

Creating/Updating/Reading JSON variables

  1. Java Service Task


Within java service task we can create JsonNode (com.fasterxml.jackson.databind.JsonNode) and set the variable.


String jsonString =  "{"
                +"\"id\": 1,"
                +"\"name\" : {\"first\" : \"Yong\",\"last\" : \"Mook Kim\"},"
                +"\"priority\" : 5"
                +"}";
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(jsonString);
execution.createVariableLocal("testJsonVar", root);

  1. An Expression

Within expressions, We can query content using functionalities provided in Jackson library.

<sequenceFlow id="flow4" sourceRef="exclusivegateway1" targetRef="usertask3">
  <conditionExpression xsi:type="tFormalExpression">
     <![CDATA[${testJsonVar.get("priority").asInt() > 10}]]>
  </conditionExpression>
</sequenceFlow>
  1. BPMN REST API

From REST API side, we cannot set JSON variable over BPMN Rest API. But possible to add that functionality by creating variable converters for JSON in REST API in WSO2 BPS v3.5.0 and v3.5.1.
  1. Script Task

Can read JSON variables and manipulate, but cannot set JSON variables within a script in WSO2 BPS v3.5.0 and v3.5.1

Saturday, April 30, 2016

Setting up hot deployment for rules stored in registry in WSO2 BRS [Business Rule Server]

In most WSO2 products, we refer registry artifact instead packaging deployment artifacts in single CAPP when we need governance facilities over those artifacts. For example, more commonly we store WSO2 ESB Synapse Configuration of a sequence as a resource (or we can call registry artifact) and refer it in main Synapse configuration.

Likewise for WSO2 BRS rule services, we can store rules in the registry and refer them in rule service descriptor (.rsl file).

Simplest Method Of using registry artifacts

In such usage, in most cases in run-time, we read it, keep in cache, and reload when cache get invalidated. Therefore, when registry resource gets updated, it will affect to the run-time when cache gets invalidated.

Issue above method in case of rule service in WSO2 BRS

During rule service deployment, the rules in forms of .drl, .xls, .csv files, Inline or registry artifacts were read and inject those rules and build DroolsKnowledgeBase, since that is expensive process BRS cannot follow simple caching procedure.

There are two methods to update rules in run-time (without redeploying rule service)  rule service when registry resource get updated.

01. Manual method 

Publish message to relevant topic related to the registry resource.
Go to Main Tab click "Browse" under Topics. Then navigate to relavent topic (if your registry artifact path is gov:sharedRules/test then the topic resource path will be /registry/notifications/ResourceUpdated/_system/governance/sharedRules/test).

Click "details" to get details view.


02. Automatically updating rules

With this method when you update registry resources, relavent KnowledgeBases of each related rule services get reloasded. For achieve this, you have to little bit fiddle with WSO2 feature installation. But worth it, and this is kind of best useful way to update rules in run-time without un-deploying/redeploying rule service in production environment.

You just need to install following three features to WSO2 BRS:

  1. Apache Axis2 - Mail Transport -version1.1.0.wso2v17
  2. Registry Community Features - version 4.4.8
  3. Registry Handler Config - version 4.4.8
Note : Refer [1] to find how to install features for wso2 brs

This is tested in WSO2 BRS v2.2.0

[1] https://docs.wso2.com/display/BRS220/Installing+Features

Sunday, March 20, 2016

Monitor WSO2 cluster using Hazelcast mancenter

All wso2 servers use hazelcast for clustering at the moment.

Hazelcast provide ootb tool to monitor in memory data grid called "mancenter" or "Management Center"[1]. It's really cool tool to try out and have in your system. You can use it to monitor wso2 server clusters with simple configuration step. Unfortunately free version of it only can handle 2 nodes. But fortunately, they provide a free 1-month trial key for evaluation. You can apply for evaluation version from [2].

Follow simple steps to monitor wso2 cluster:
  1. Download hazelcast from [3].
  2. Extract and you can find mancenter.war at <extracted_dir>/hazelcast-3.5.2/mancenter.
  3. Deploy it in Tomcat by copying it to <TOMCAT_HOME>/webapps and start tomcat server if not already started.
  4. You can find mancenter by following URL http://localhost:<tomcat port>/mancenter.
  5. Update clustering configuration of WSO2 product.
    • Open <PRODUCT_HOME>/repository/conf/axis2/axis2.xml using your favourite text editor and update "mgtCenterURL" parameter under "clustering" element as follows:

  6. Start WSO2 servers. Refer WSO2 Clustering and Deployement Guide [4] if you need information about WSO2 product clustering.
  7. Then goto mancenter url (refresh if you already loaded), and login with username : admin and password : admin
  8. After you login you have to select the relevant cluster domain and click "connect"
  9. The Management Center Dashboard will be as follows. It lists all the nodes in the cluster and statistics.
  10. And also you can monitor all the runtime information suchas memory ussage, load average, etc. of each node.




[1] https://hazelcast.com/products/management-center/
[2] https://hazelcast.com/hazelcast-enterprise-download/trial/
[3] http://hazelcast.org/download/
[4] https://docs.wso2.com/display/CLUSTER44x/WSO2+Clustering+and+Deployment+Guide

Monday, February 29, 2016

Start BPMN Process by Listening to a Message Queue



There are several types of start events available in BPMN. First of all if you are not much familiar with BPMN processes here is some summary information about Start events, summarized from BPMN specification

Start Enevts

  • The Start Event simply indicates where the process start (entry points to process)
  • When trigger for start event occurs, a new process instance get created
  • There are 7 types of start events for top-level BPMN processes: None, Message, Timer, Conditional, Signal, Multiple, and Parallel





  • All the start events, except None Start Event, only applicable to processes used as top level process. None Start Event may used to invoke process from Call Activity
Now we will concentrate main topic of this post

Start BPMN Process by Listening to a Message Queue/Topic

WSO2 BPS 3.5.0/3.5.1 do not support starting bpmn process by listening to a message queue. But that feature will be available OOTB in a future release. At the moment we have to achieve that with the help of WSO2 ESB.

Things you need:
  1. WSO2 Enterprise Service Bus (WSO2 ESB 4.9.0 used for this post)
  2. WSO2 Business Process Server (WSO2 BPS 3.5.1 used for this post. You must have BPS 3.5.0 or higher version for BPMN support)
  3. ActiveMQ (5.12.0 used for this post or you can use WSO2 Message Broker too)

Architecture diagram




BPMNProcess_start_proxy is ESB proxy that consumes messages from the queue, create relevant message to start the bpmn process and make REST call to start the bpmn process. In this case ESB acts as message consumer of the queue.

Step 01 : Create BPMN process 

Follow [1] for basic guide to create BPMN process

Here is the BPMN process that I'm going to use


You can download it from [2]

This sample process shows approval process for placing a stock order. If the entire investment is greater that $100,000 and administrator should approve it.

Stem 02 : Configure WSO2 ESB

  • First you have to enable JMS transport of WSO2 ESB. You can find instruction in [3] to configure WSO2 ESB for ActiveMQ and [4] for WSO2 Message Broker. Refer [5] for other popular massage brokers.
  • Create BPMNProcess_start_proxy proxy service
    • This proxy service receive stock order message and start order approval BPMN process deployed in WSO2 BPS. The proxy extract relevent information and create JSON request including those data as variables and invoke BPMN REST API available in WSO2 BPS.

Step 03 : Start Servers

Start ActiveMQ
Start WSO2 ESB (default port, portOffset=0, 9443)
Start WSO2 BPS (portOffset=1, 9444): start $ sh bin/wso2server.sh -DportOffset=1

Step 04 : Make Stock order 

Make Stock order request to "StockOrderInQueue" message queue
Execute StockQuote Client : navigate to /samples/axis2Client and execute following command

ant stockquote -Dmode=placeorder -Dtrpurl="jms:/StockOrderInQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.ContentTypeProperty=Content-Type&transport.jms.DestinationType=queue"

User tasks can be completed using bpmn-explorer webapp (https://localhost:9444/bpmn-explorer) and login as ‘admin’

As shown above you can start BPMN process by listening to message queue. By integration with WSO2 ESB you can start BPMN process, using any type of transport that WSO2 ESB support for example: JMS, Kafka[6].

References:
[1] https://docs.wso2.com/display/BPS350/BPMN+Guide
[2] https://github.com/milindaperera/MilisLogBlog/tree/master/WSO2BPS/BPMN/BPMN_ESB_MQ_Integration
[3] https://docs.wso2.com/display/ESB490/Configure+with+ActiveMQ
[4] https://docs.wso2.com/display/ESB490/Configure+with+WSO2+Message+Broker
[5] https://docs.wso2.com/display/ESB490/Configuring+JMS+Transport
[6] https://docs.wso2.com/display/ESB490/Kafka+Inbound+Protocol

If this post is useful to you, any questions, corrections or for any suggestion, please leave a comment below :)