Mulesoft: Twilio API Integration

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

mulesoft-logoplustwilio

Twilio is a cloud based communication company that enables users to use standard web languages to build voice, VoIP, and SMS apps via a web API. Twilio provides a simple hosted API and markup language for businesses to quickly build scalable, reliable and advanced voice and SMS communications applications. Twilio based telephony infrastructure enable web programmer to integrate real time phone call, SMS or VOIP to their application.

Mulesoft provides cloud connector to integrate Twilio Api within Mulesoft. Mulesoft Cloud connector provides a simple and easy way to integrate with these Twilio APIs, and then use them as services within Mulesoft. Mulesoft-Twilio connector provides a platform for developer to develop and integrate their application easily and quickly with Twilio.

Before start integration of Mulesoft with Twilio, create your Twilio account and get “ACCOUNT SID” and “AUTH TOKEN”.

twilio-account

Now download and install Twilio connector into Anypoint studio.

Anypoint Studio –>Help –>Install New Software

twilio-connector

Configure pom.xml to pull Twilio jar dependency in maven based project.

Add plugin in plugin section and dependency in pom.xml file. This section will also add into pom.xml file when Twilio connector drag into AnypointStudio canvas and use it into flow.

<plugin>
   <groupId>org.mule.tools.maven</groupId>
<artifactId>mule-app-maven-plugin</artifactId>
<version>${mule.tools.version}</version>
<extensions>true</extensions>
<configuration>
<copyToAppsDirectory>true</copyToAppsDirectory>
<inclusions>
<inclusion>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-apikit</artifactId>
</inclusion>
        <inclusion>
                   <groupId>org.mule.modules</groupId>
                   <artifactId>mule-module-twilio</artifactId>
         </inclusion>
     </inclusions>
</configuration>
</plugin>

Dependency tag

<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-twilio</artifactId>
<version>1.4</version>
</dependency>

Now configure Twilio Global Elements to connect your application with Twilio into Mule-config.xml file

<twilio:config name="Twilio" accountSid="${TwilioSID}" authToken="${TwilioAuthToken}" doc:name="Twilio">
<twilio:http-callback-config />
</twilio:config>

In above code TwilioSID and TwilioAuthToken are coming from Twilio account.

Mulesoft Twilio connector provides a  number of methods to integrate with your application. Below image show some of methods expose by Mulesoft-Twilio connector.

twilio-method

I am using “send SMS message” method form Mulesoft-Twilio connector for my example.

Now you can integrate Twilio to send SMS with your application. Here is example code.

<logger message="#[payload.recipientPhoneNumber]" level="INFO" doc:name="Logger"/>
<twilio:send-sms-message config-ref="Twilio" accountSid="${TwilioSID}" body="Hello World Sending SMS from Twilio" from="+15555555555" to="#[payload.recipientPhoneNumber]" doc:name="Twilio"/>

Twilio API does not support bulk SMS for recipient. So, to initiate messages to a list of recipients, you must make a request for each number to which you would like to send a message. The best way to do this is to build an array of the recipients and iterate through each phone number.

Here is small flow for Twilio integration.

twilio-flow

Code for this flow.

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:twilio="http://www.mulesoft.org/schema/mule/twilio" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/twilio http://www.mulesoft.org/schema/mule/twilio/current/mule-twilio.xsd">

<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<twilio:config name="Twilio" accountSid="${TwilioSID}" authToken="${TwilioAuthToken}" doc:name="Twilio">
    <twilio:http-callback-config />
</twilio:config>
  <flow name="twilio-mulesoftFlow">
     <http:listener config-ref="HTTP_Listener_Configuration" path="/twilio" doc:name="HTTP"/>
     <set-payload value="" doc:name="Set Payload"/>
     <logger message="#[payload.recipientPhoneNumber]" level="INFO" doc:name="Logger"/>
     <twilio:send-sms-message config-ref="Twilio" acc#[payload.recipientPhoneNumber]: #339966;">${TwilioSID}" body="#[payload]" from="+15555555555" to="+12222222222" doc:name="Twilio"/>
  </flow>
</mule>

If you are getting exception, make sure twilio-mulesoft jar is in classpath and properly configured.

Mulesoft Polling : A New Perspective

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

Mulesoft polling is one of the most important features in Mulesoft. If you are dealing with large set of data or asynchronous workflow, polling architect is one of the best options to manage this scenario.
There are two options to configure Mulesoft poll scheduling.

  1. Fixed frequency scheduler – you can define polling time in frequency, start delay and time unit. This is one of the simplest ways to define your polling.
  2. Cron scheduler – Cron scheduler gives ability to use expression language and manage complex scheduling polling.

There is no relationship between two polling. This was challenge for me to get the relationship between two polling so that I can manage my data more efficiently.

Mulesoft gives couple of options to set up relationship between two polls.

Watermark – In polling there is always challenge to process newly created data and keep persist pointer for processed data to avoid duplicate processing. Mulesoft allows us as Watermark to persist this pointer in objectstore. Mule sets a watermark to a default value the first time the flow runs, then uses it as necessary when running a query or making an outbound request. Based on flow Mule may update the original value of the watermark or maintain the original value.
Here is simple flow to show how to implement watermark for poll

Poll Watermark Flow Diagram
poll-watermark

Here is code for this flow


<?xml version="1.0" encoding="UTF-8"?>
  <mule xmlns:schedulers="http://www.mulesoft.org/schema/mule/schedulers" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
   xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
   xmlns:spring="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
   http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
   http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
   http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
   http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
   http://www.mulesoft.org/schema/mule/schedulers http://www.mulesoft.org/schema/mule/schedulers/current/mule-schedulers.xsd">
  <spring:beans>
     <spring:bean id="dataSourceBean" name="dataSource_Bean" class="org.apache.commons.dbcp.BasicDataSource">
       <spring:property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
       <spring:property name="username" value="********"/>
       <spring:property name="password" value="********* "/>
       <spring:property name="url" value="jdbc:jtds:sqlserver://localhost:60520;Instance=CRM;DatabaseName=vanrish;domain=man;integrated security=false"/>
    </spring:bean>
 </spring:beans>
  <db:generic-config name="Generic_Database_Configuration" dataSource-ref="dataSourceBean" doc:name="Generic Database Configuration" >
     <reconnect-forever frequency="30000"/>
  </db:generic-config>
<flow name="poll-watermarking" processingStrategy="synchronous">
  <poll doc:name="Poll">
    <schedulers:cron-scheduler expression="0 22 12 * * ?"/>
    <watermark variable="serialNumber" default-expression="0" selector="LAST" selector-expression="#[payload.serialNumber]"/>
    <db:select config-ref="Generic_Database_Configuration" doc:name="Select Database">
       <db:dynamic-query><![CDATA[SELECT
MessageId, MessageType,SerialNumber,CreatedOn  FROM Message where SerialNumber  > #[Integer.parseInt(flowVars['serialNumber'])] order by SerialNumber asc]]></db:dynamic-query>
    </db:select>
 </poll>
   <logger message="#[flowVars['serialNumber']] == Hello this is Loggin Message == #[payload]" level="INFO" doc:name="Logger"/>
  </flow>
</mule>

Idempotent Filter – Idempotent filter is another way in Mule we can keep track between two polling. This filter ensures that only unique messages are received by a service by checking the unique ID of the incoming message. This filter also store unique id/pointer in objectstore in mule.
Here is simple flow to use Idempotent Filter

Poll Idempotent Filter flow Diagram
poll-idempotent

idempotent-objectStore

Here is code

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:schedulers="http://www.mulesoft.org/schema/mule/schedulers" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:db="http://www.mulesoft.org/schema/mule/db"
  xmlns:cassandradb="http://www.mulesoft.org/schema/mule/cassandradb" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
  xmlns:spring="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
  http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
  http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
  http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
  http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
  http://www.mulesoft.org/schema/mule/schedulers http://www.mulesoft.org/schema/mule/schedulers/current/mule-schedulers.xsd">
    <spring:beans>
      <spring:bean id="dataSourceBean" name="dataSource_Bean" class="org.apache.commons.dbcp.BasicDataSource">
        <spring:property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
        <spring:property name="username" value="*******"/>
        <spring:property name="password" value="********"/>
        <spring:property name="url" value="jdbc:jtds:sqlserver://localhost:60520;Instance=CRM;DatabaseName=vanrish;domain=man;integrated security=false"/>
      </spring:bean>
    </spring:beans>
    <db:generic-config name="Generic_Database_Configuration" dataSource-ref="dataSourceBean" doc:name="Generic Database Configuration" >
      <reconnect-forever frequency="30000"/>
    </db:generic-config>
    <flow name="poll-idempotent" processingStrategy="synchronous">
      <poll doc:name="Poll">
        <fixed-frequency-scheduler frequency="10000"/>
        <db:select config-ref="Generic_Database_Configuration" doc:name="Select Database">
          <db:dynamic-query><![CDATA[SELECT  MessageId, MessageType,SerialNumber,CreatedOn  FROM Message order by SerialNumber asc]]></db:dynamic-query>
        </db:select>
      </poll>
      <foreach doc:name="For Each">
        <idempotent-message-filter idExpression="#[payload.SerialNumber]" doc:name="Idempotent Message">
          <in-memory-store entryTTL="120000" expirationInterval="1800000"/>
        </idempotent-message-filter>
        <logger message="#[payload.SerialNumber] == Hello this is Loggin Message == #[payload]" level="INFO" doc:name="Logger"/>
      </foreach>
    </flow>
  </mule>

MuleSoft Security – Encryption

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

Security is about protecting your assets. These assets could be anything in company. Please refer to my previous blog about  what-is-security.

Mulesoft provides security suite to protect company assets. This suite of security features provides various methods for applying security to Mule Service-Oriented Architecture (SOA) implementations and Web services. Mulesoft security suits are available in enterprise version of Mulesoft.

In this blog I am showing, how to use Encryption and Decryption from Mulesoft Security suits. Mule can encrypt an entire payload or several fields of data within a message. This encryption prevents unauthorized access of data like password, SSN, credit card… etc. and moves this data between systems securely.

Mule Message Encryption processor changes the payload or Message so that it becomes unreadable by unauthorized entities. Mule Encryption processor encrypts the payload using one of the following three Encryption Strategies

1) JCE Encrypter — encrypts stream, byte[] or string
2) XML Encrypter — encrypts string, encrypts individual fields using xpath expressions.
3) PGP Encrypter — encrypts stream, byte[] or string, applies tighter security (relative to JCE and XML), increases processing load (relative to JCE and XML)

Encryption-Decryption Flow Diagram
securitydemoproject
Encryption Connector Configuration
In my example I am using Jce Encrypter. I am setting value for key and keypassword
encryption_connector
Here is full code of this implementation


<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:encryption="http://www.mulesoft.org/schema/mule/encryption" 
xmlns:http="http://www.mulesoft.org/schema/mule/http" 
xmlns="http://www.mulesoft.org/schema/mule/core" 
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"       
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.7.0"       
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/encryption http://www.mulesoft.org/schema/mule/encryption/current/mule-encryption.xsd">

  <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" basePath="/demo" doc:name="HTTP Listener Configuration"/>
  <encryption:config name="Encryption" doc:name="Encryption">
    <encryption:jce-encrypter-config key="8aVrj8x8IevyeaD=" keyPassword="0Zb+smauaT8v6hRiFGJDnakwlS/YC2u="/>    </encryption:config>

  <flow name="securitydemoprojectFlow">

    <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>

    <set-payload value="Hello World" doc:name="Set Payload"/>

    <encryption:encrypt config-ref="Encryption" doc:name="Encryption" using="JCE_ENCRYPTER">

      <encryption:jce-encrypter key="8aVrj8x8IevyeaD=" algorithm="AES" encryptionMode="CBC" keyPassword="0Zb+smauaT8v6hRiFGJDnakwlS/YC2u="/>

    </encryption:encrypt>

    <logger message=" Encrypted Message ==#[payload]" level="INFO" doc:name="Logger"/>

    <encryption:decrypt config-ref="Encryption" doc:name="Decryption" using="JCE_ENCRYPTER">

      <encryption:jce-encrypter key="8aVrj8x8IevyeaD=" keyPassword="0Zb+smauaT8v6hRiFGJDnakwlS/YC2u=" algorithm="AES" encryptionMode="CBC"/>

    </encryption:decrypt>
  </flow>
</mule>

Mulesoft Parallel processing-2 (Splitter,Collection Splitter, Chunk Splitter)

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

I described in my previous blog about parallel processing, in this blog also I am continuing my previous blog but adding new flavor of parallel processing in Mulesoft.
Splitter flow control splits a message into separate fragments and then sends these fragments parallel and concurrent to the next message processor in the flow. Segments are identified based on an expression parameter, usually written in Mule Expression Language (MEL), but other formats can be employed also. There are three ways we can spilt Mulesoft message.

Splitter — Splitter can split all types of data like Object, XML, JSON, and Payload based on MEL (Mule expression language) and processes each split into individual thread. .

Collection Splitter – If input type is collection, then collection splitter split data based on collection and process each element in individual thread.

Chunk Splitter – Chunk of splitter spilts message into chunk of bytes based on user input and processes each chunk of bytes in individual thread.

Since Collection splitter is one of the most usable splitter in Mulesoft. So I am showing example about Collection splitter.
In this example HasMap is coming as payload. Collection Splitter splits HasMap into different threads (limiting max 50 threads) and processes these threads in parallel.

 Flow diagrame to implement parallel processing through Mulesoft Collection Splitter
splitter

Mulesoft code for parallel processing (Splitter)

<flow name="Vanrish-processFlow" processingStrategy="allow50Threads">

    <logger message="*** Starting Vanrish-processFlow ***" category="edi-vanrish-process" level="INFO" doc:name="Flow Start Log"/>

    <set-payload value="#[map-payload:processing]" doc:name="Payload Processing"/>
    <set-variable variableName="numberOfMessages" value="#[payload.entrySet().size()]" doc:name="Variable"/>
    <logger message="Processing #[flowVars['numberOfMessages']] entities" level="INFO" doc:name="logger-status go to database"/>
    <splitter doc:name="Collection Splitter" expression="#[payload.entrySet()]"/>
    <vm:outbound-endpoint exchange-pattern="one-way" path="VanrishVM" doc:name="VM"/>

    <logger message="*** Ending Vanrish-processFlow ***" category="edi-Vanrish-process" level="INFO" doc:name="Flow End Log"/>
</flow>

<flow name="Vanrish_Splitter_Demo" processingStrategy="allow50Threads">
    <vm:inbound-endpoint exchange-pattern="one-way" path="VanrishVM" doc:name="VM"/>
    <logger message="Company Canonical Start Time -&gt; #[server.dateTime]" level="INFO" doc:name="Company Logger"/>
    <flow-ref name="vanrishMsgPrivateFlow" doc:name="companyMsgPrivateFlow"/>
</flow>

Java Profiler is to show how Mulesoft Splitter splits collection message into multiple threads and process data
splitter-profiler

REST API Descriptive Language (API DL)

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

Rest (Representational State Transfer) webservice style is getting widespread acceptance across the Web fraternity. Industries and software communities are looking alternative to SOAP and WSDL based webservice. To compete with SOAP and WSDL based webservice REST need to support Descriptive Language based API.

Webservices APIs that follow and apply to the REST architectural constraints are called RESTful APIs. API descriptive language need to include blueprint of service, contract of service, metadata of service and documentation of service.

Many REST API descriptive language (API DL) are available today. Here I am discussing top 3 active API DL available for REST.

restapi

RAML — RAML is sponsored by MuleSoft. RAML Built on broadly used standards such as YAML and JSON, written in CoffeeScript, and can be used as a node.js. This is one of the very famous API DL and widely use with MuleSoft ESB. RAML support blueprint and contract of service design before you start your original coding. RAML API design approach is top-down. Writing spec for RAML is simple, human readable format.

SWAGGER – Sawwagger is sponsored by couple of companies like Apigee, Reverb and supported  with a large number active developer communities. Swaager format is based on JSON but they also support YAML. Swagger right now doesn’t support design before code. SWAGGER API design approach is bottom-up. Writing spec for SWAGGER  looks incomplete.

API Blueprint – API blueprint is sponsored by Apiary.API blueprint is based on Markdown. Markdown is a text-to-HTML conversion tool for web writers. There is no active developer community support for API Blueprint. API Blueprint right now doesn’t support design before code and its design approach is top-down. Writing spec for API Blueprint is simple and easy.

New Feature of Mule ESB 3.6 released and Anypoint studio

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

Mule ESB is one of the leading open sources ESB in market. Mule ESB product is maturing every day. Recently it released new version of Mule 3.6 and Anypoint studio January 2015 to support development for Mule 3.6 released. This release of mule adopts design-first and resource based approach. With this release user can quickly connect and design API based on a new HTTP connector.anypoint-platform-release
Here is quick view of some of enhancement with Mule 3.6
1. New Http connector – New http connector is more resource centric, simpler to use and allow using RAML specs.
2. Shared Resources – New released support shared resources allow to share connector across multiple project and application. This is managed by new project inside Mule editor called Domain.
3. Continuous Integration enhancement — This release features a powerful new agent that provides access to MuleSoft’s runtime API for integrating with existing continuous integration processes and SDLC tools like Jenkins
4. New Support for Microsoft – Sharepoint and Dynamics CRM are two new connectors to integrate with Microsoft services.
5. AMQP 0.9 connector – This connector is now officially part of Mule soft connector. It is built on top of the previously-available community AMQP transport, and includes support for multi-channel receivers

Integration of JBPM and spring with Mule ESB

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

Mule, JBPM and spring framework is one of the best combinations to implement SOA framework. These combinations are very famous among open source and easy to implement. Integration among this technology is always a challenge. I am adding some integration bullet point to make this integration easy.
These file are involved to integration among JBPM, spring and Mule ESB.
1) ApplicationContext.xml – spring framework
2) mule-config.xml – Mule ESB
3) jbpm.cfg.xml – JBPM file
4) All library for spring, JBPM and Mule ESB jar file
mule-config.xml
Add these lines into mule-config.xml file

  1. <mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
  2. ..... xmlns:bpm="http://www.mulesource.org/schema/mule/bpm/2.2" xmlns:spring-context="http://www.springframework.org/schema/context" xmlns:spring="http://www.springframework.org/schema/beans" ... >
  3. <spring:beans> <spring:import resource="applicationContext.xml"/> </spring:beans> <spring:bean id="jbpm-ref" parent="jbpm" />
  4. <bpm:connector name="jBpmConnector" bpms-ref="jbpm-ref" allowGlobalReceiver="true" allowGlobalDispatcher="true" processIdField="requestId"> <custom-exception-strategy class="com.vanrish.exception.ApplicationExceptionStrategy"/> <!—This is custom exception class based on your business logic -->< </bpm:connector>

applicationContext.xml
This is spring specific file. So we are defining jbpm specific configuration to call from mule.


    <bean id="jbpm" class="org.mule.transport.bpm.jbpm.JbpmImpl" destroy-method="destroy"> <property name="configuration"> <value>classpath:jbpm.cfg.xml</value> </property> property name="processDefinitionsResources"> <list> <value>classpath:verifyAge.xml</value> ..... <!-- Define JBPM specific process file --> </list> </property> <property name="createSchema"> <value>false</value> </property> </bean>

JBoss Messaging Configuration

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

1.     Introduction

JBoss Messaging is a high performance JMS provider in the JBoss Enterprise Middleware Stack (JEMS). JBoss Messaging is the default JMS provider in JBoss AS 5.x and later.

2.     Features 

  • A fully compatible and Sun certified JMS 1.1 implementation.
  • A strong focus on performance, reliability and scalability with high output and low latency.
  • Publish-subscribe and point-to-point messaging models.
  • Topics that feed multiple message queues
  • Persistent and non-persistent messages
  • Guaranteed message delivery that ensures that messages arrive once and only once
  • Transactional and reliable – supporting ACID semantics
  • Customizable security framework based on JAAS

3.     JBoss-JMS Configuration

3.1.Configuration-Queue

  • Create queue-destination-service.xml file in \deploy\messaging folder for jboss 5.x
  • Here is sample xml file

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <server>
  3. <mbean code="org.jboss.jms.server.destination.QueueService" name="jboss.messaging.destination:service=Queue,name=testQueue" xmbean-dd="xmdesc/Queue-xmbean.xml">
  4. <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
  5. <depends>jboss.messaging:service=PostOffice</depends>
  6. <attribute name="SecurityConfig">
  7. <security>
  8. <role name="guest" read="true" write="true"/>
  9. <role name="publisher" read="true" write="true" create="false"/>
  10. <role name="noacc" read="false" write="false" create="false"/>
  11. </security>
  12. </attribute>
  13. </mbean>
  14. </server>
  • Restart Jboss server

3.2.Configuration-Topic

  • Create topic-destination-service.xml file in \deploy\messaging folder for jboss 5.x
  • Here is sample xml file

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <server>
  3. <mbean code="org.jboss.jms.server.destination. TopicService" name="jboss.messaging.destination:service=Topic,name= testTopic" xmbean-dd="xmdesc/Queue-xmbean.xml">
  4. <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
  5. <depends>jboss.messaging:service=PostOffice</depends>
  6. <attribute name="SecurityConfig">
  7. <security>
  8. <role name="guest" read="true" write="true"/>
  9. <role name="publisher" read="true" write="true" create="false"/>
  10. <role name="noacc" read="false" write="false" create="false"/>
  11. </security>
  12. </attribute>
  13. </mbean>
  14. </server>
  • Restart Jboss server

4.     JBoss-Oracle configuration for JMS

Create these tables in Oracle database


  1. CREATE TABLE JBM_DUAL (DUMMY INTEGER, PRIMARY KEY (DUMMY))
  2. CREATE TABLE JBM_MSG_REF (MESSAGE_ID INTEGER, CHANNEL_ID INTEGER, TRANSACTION_ID INTEGER, STATE CHAR(1), ORD INTEGER, PAGE_ORD INTEGER, DELIVERY_COUNT INTEGER, SCHED_DELIVERY INTEGER, PRIMARY KEY(MESSAGE_ID, CHANNEL_ID))
  3. CREATE INDEX JBM_MSG_REF_TX ON JBM_MSG_REF (TRANSACTION_ID, STATE)
  4. CREATE TABLE JBM_MSG (MESSAGE_ID INTEGER, RELIABLE CHAR(1), EXPIRATION INTEGER, TIMESTAMP INTEGER, PRIORITY INTEGER, TYPE INTEGER, HEADERS BLOB, PAYLOAD BLOB, PRIMARY KEY (MESSAGE_ID))
  5. CREATE TABLE JBM_TX (NODE_ID INTEGER, TRANSACTION_ID INTEGER, BRANCH_QUAL RAW(254), FORMAT_ID INTEGER, GLOBAL_TXID RAW(254), PRIMARY KEY (TRANSACTION_ID))
  6. CREATE TABLE JBM_COUNTER (NAME VARCHAR2(255), NEXT_ID INTEGER, PRIMARY KEY(NAME))
  7. CREATE TABLE JBM_ID_CACHE (NODE_ID INTEGER, CNTR INTEGER, JBM_ID VARCHAR2(255), PRIMARY KEY(NODE_ID, CNTR))
  8. CREATE TABLE JBM_POSTOFFICE (POSTOFFICE_NAME VARCHAR2(255), NODE_ID INTEGER, QUEUE_NAME VARCHAR2(255), COND VARCHAR2(1023), SELECTOR VARCHAR2(1023), CHANNEL_ID INTEGER, CLUSTERED CHAR(1), ALL_NODES CHAR(1), PRIMARY KEY(POSTOFFICE_NAME, NODE_ID, QUEUE_NAME))
  9. CREATE TABLE JBM_USER (USER_ID VARCHAR2(32) NOT NULL, PASSWD VARCHAR2(32) NOT NULL, CLIENTID VARCHAR2(128), PRIMARY KEY(USER_ID))
  10. CREATE TABLE JBM_ROLE (ROLE_ID VARCHAR2(32) NOT NULL, USER_ID VARCHAR2(32) NOT NULL, PRIMARY KEY(USER_ID, ROLE_ID))

In order to enable support for one of these databases, just replace the default hsqldb-persistence-service.xml configuration file with the Oracle database-specific configuration file in \deploy\messaging folder.

Here is oracle specific persistence file.

oracle-persistence-service.xml


  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Oracle persistence deployment descriptor.
  4. Tested with Oracle 10.2.0.1
  5. $Id$
  6. -->
  7. <server>
  8. <!-- Persistence Manager MBean configuration======================================== -->
  9. <mbean code="org.jboss.messaging.core.jmx.JDBCPersistenceManagerService" name="jboss.messaging:service=PersistenceManager" xmbean-dd="xmdesc/JDBCPersistenceManager-xmbean.xml">
  10. <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
  11. <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
  12. <!-- The datasource to use for the persistence manager -->
  13. <attribute name="DataSource">java:/DefaultDS</attribute>
  14. <!-- If true will attempt to create tables and indexes on every start-up -->
  15. <attribute name="CreateTablesOnStartup">true</attribute>
  16. <!-- If true then we will automatically detect and reject duplicate messages sent during failover -->
  17. <attribute name="DetectDuplicates">true</attribute>
  18. <!-- The size of the id cache to use when detecting duplicate messages -->
  19. <attribute name="IDCacheSize">500</attribute>
  20. <!-- Some databases don't support inserting blobs using INSERT INTO ... SELECT FROM -->
  21. <attribute name="SupportsBlobOnSelect">false</attribute>
  22. <attribute name="SqlProperties"><![CDATA[
  23. CREATE_DUAL=CREATE TABLE JBM_DUAL (DUMMY INTEGER, PRIMARY KEY (DUMMY))
  24. CREATE_MESSAGE_REFERENCE=CREATE TABLE JBM_MSG_REF (MESSAGE_ID INTEGER, CHANNEL_ID INTEGER, TRANSACTION_ID INTEGER, STATE CHAR(1), ORD INTEGER, PAGE_ORD INTEGER, DELIVERY_COUNT INTEGER, SCHED_DELIVERY INTEGER, PRIMARY KEY(MESSAGE_ID, CHANNEL_ID))
  25. CREATE_IDX_MESSAGE_REF_TX=CREATE INDEX JBM_MSG_REF_TX ON JBM_MSG_REF (TRANSACTION_ID, STATE)
  26. CREATE_MESSAGE=CREATE TABLE JBM_MSG (MESSAGE_ID INTEGER, RELIABLE CHAR(1), EXPIRATION INTEGER, TIMESTAMP INTEGER, PRIORITY INTEGER, TYPE INTEGER, HEADERS BLOB, PAYLOAD BLOB, PRIMARY KEY (MESSAGE_ID))
  27. CREATE_TRANSACTION=CREATE TABLE JBM_TX (NODE_ID INTEGER, TRANSACTION_ID INTEGER, BRANCH_QUAL RAW(254), FORMAT_ID INTEGER, GLOBAL_TXID RAW(254), PRIMARY KEY (TRANSACTION_ID))
  28. CREATE_COUNTER=CREATE TABLE JBM_COUNTER (NAME VARCHAR2(255), NEXT_ID INTEGER, PRIMARY KEY(NAME))
  29. CREATE_ID_CACHE=CREATE TABLE JBM_ID_CACHE (NODE_ID INTEGER, CNTR INTEGER, JBM_ID VARCHAR2(255), PRIMARY KEY(NODE_ID, CNTR))
  30. INSERT_DUAL=INSERT INTO JBM_DUAL VALUES (1)
  31. CHECK_DUAL=SELECT 1 FROM JBM_DUAL
  32. INSERT_MESSAGE_REF=INSERT INTO JBM_MSG_REF (CHANNEL_ID, MESSAGE_ID, TRANSACTION_ID, STATE, ORD, PAGE_ORD, DELIVERY_COUNT, SCHED_DELIVERY) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
  33. DELETE_MESSAGE_REF=DELETE FROM JBM_MSG_REF WHERE MESSAGE_ID=? AND CHANNEL_ID=? AND STATE='C'
  34. UPDATE_MESSAGE_REF=UPDATE JBM_MSG_REF SET TRANSACTION_ID=?, STATE='-' WHERE MESSAGE_ID=? AND CHANNEL_ID=? AND STATE='C'
  35. UPDATE_PAGE_ORDER=UPDATE JBM_MSG_REF SET PAGE_ORD = ? WHERE MESSAGE_ID=? AND CHANNEL_ID=?
  36. COMMIT_MESSAGE_REF1=UPDATE JBM_MSG_REF SET STATE='C', TRANSACTION_ID = NULL WHERE TRANSACTION_ID=? AND STATE='+'
  37. COMMIT_MESSAGE_REF2=DELETE FROM JBM_MSG_REF WHERE TRANSACTION_ID=? AND STATE='-'
  38. ROLLBACK_MESSAGE_REF1=DELETE FROM JBM_MSG_REF WHERE TRANSACTION_ID=? AND STATE='+'
  39. ROLLBACK_MESSAGE_REF2=UPDATE JBM_MSG_REF SET STATE='C', TRANSACTION_ID = NULL WHERE TRANSACTION_ID=? AND STATE='-'
  40. LOAD_PAGED_REFS=SELECT MESSAGE_ID, DELIVERY_COUNT, PAGE_ORD, SCHED_DELIVERY FROM JBM_MSG_REF WHERE CHANNEL_ID = ? AND PAGE_ORD BETWEEN ? AND ? ORDER BY PAGE_ORD
  41. LOAD_UNPAGED_REFS=SELECT MESSAGE_ID, DELIVERY_COUNT, SCHED_DELIVERY, PAGE_ORD FROM JBM_MSG_REF WHERE STATE = 'C' AND CHANNEL_ID = ? ORDER BY ORD
  42. LOAD_REFS=SELECT MESSAGE_ID, DELIVERY_COUNT, SCHED_DELIVERY FROM JBM_MSG_REF WHERE STATE = 'C' AND CHANNEL_ID = ? ORDER BY ORD
  43. UPDATE_REFS_NOT_PAGED=UPDATE JBM_MSG_REF SET PAGE_ORD = NULL WHERE PAGE_ORD BETWEEN ? AND ? AND CHANNEL_ID=?
  44. SELECT_MIN_MAX_PAGE_ORD=SELECT MIN(PAGE_ORD), MAX(PAGE_ORD) FROM JBM_MSG_REF WHERE CHANNEL_ID = ?
  45. UPDATE_DELIVERY_COUNT=UPDATE JBM_MSG_REF SET DELIVERY_COUNT = ? WHERE MESSAGE_ID = ? AND CHANNEL_ID = ?/li>
  46. UPDATE_CHANNEL_ID=UPDATE JBM_MSG_REF SET CHANNEL_ID = ? WHERE CHANNEL_ID = ?
  47. MOVE_REFERENCE=UPDATE JBM_MSG_REF SET CHANNEL_ID = ? WHERE MESSAGE_ID = ? AND CHANNEL_ID = ?
  48. LOAD_MESSAGES=SELECT MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE FROM JBM_MSG
  49. INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE, HEADERS, PAYLOAD) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
  50. INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE) SELECT ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)
  51. UPDATE_MESSAGE_4CONDITIONAL=UPDATE JBM_MSG SET HEADERS=?, PAYLOAD=? WHERE MESSAGE_ID=?
  52. INSERT_MESSAGE_CONDITIONAL_FULL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE, HEADERS, PAYLOAD) SELECT ?, ?, ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)
  53. MESSAGE_ID_COLUMN=MESSAGE_ID
  54. DELETE_MESSAGE=DELETE FROM JBM_MSG WHERE MESSAGE_ID = ? AND NOT EXISTS (SELECT JBM_MSG_REF.MESSAGE_ID FROM JBM_MSG_REF WHERE JBM_MSG_REF.MESSAGE_ID = ?)
  55. INSERT_TRANSACTION=INSERT INTO JBM_TX (NODE_ID, TRANSACTION_ID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID) VALUES(?, ?, ?, ?, ?)
  56. DELETE_TRANSACTION=DELETE FROM JBM_TX WHERE NODE_ID = ? AND TRANSACTION_ID = ?
  57. SELECT_PREPARED_TRANSACTIONS=SELECT TRANSACTION_ID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID FROM JBM_TX WHERE NODE_ID = ?
  58. SELECT_MESSAGE_ID_FOR_REF=SELECT MESSAGE_ID, CHANNEL_ID FROM JBM_MSG_REF WHERE TRANSACTION_ID = ? AND STATE = '+' ORDER BY ORD
  59. SELECT_MESSAGE_ID_FOR_ACK=SELECT MESSAGE_ID, CHANNEL_ID FROM JBM_MSG_REF WHERE TRANSACTION_ID = ? AND STATE = '-' ORDER BY ORD
  60. UPDATE_COUNTER=UPDATE JBM_COUNTER SET NEXT_ID = ? WHERE NAME=?
  61. SELECT_COUNTER=SELECT NEXT_ID FROM JBM_COUNTER WHERE NAME=? FOR UPDATE
  62. INSERT_COUNTER=INSERT INTO JBM_COUNTER (NAME, NEXT_ID) VALUES (?, ?)
  63. SELECT_ALL_CHANNELS=SELECT DISTINCT(CHANNEL_ID) FROM JBM_MSG_REF
  64. UPDATE_TX=UPDATE JBM_TX SET NODE_ID=? WHERE NODE_ID=?
  65. UPDATE_ID_IN_CACHE=UPDATE JBM_ID_CACHE SET JBM_ID = ? WHERE NODE_ID = ? AND CNTR = ?
  66. INSERT_ID_IN_CACHE=INSERT INTO JBM_ID_CACHE (NODE_ID, CNTR, JBM_ID) VALUES (?, ?, ?)
  67. LOAD_ID_CACHE=SELECT CNTR, JBM_ID FROM JBM_ID_CACHE WHERE NODE_ID = ?
  68. ]]></attribute>
  69. <!-- The maximum number of parameters to include in a prepared statement -->
  70. <attribute name="MaxParams">500</attribute>
  71. </mbean>
  72. <!-- Messaging Post Office MBean configuration========================================= -->
  73. <mbean code="org.jboss.messaging.core.jmx.MessagingPostOfficeService" name="jboss.messaging:service=PostOffice" xmbean-dd="xmdesc/MessagingPostOffice-xmbean.xml">
  74. <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
  75. <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
  76. <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
  77. <!-- The name of the post office -->
  78. <attribute name="PostOfficeName">JMS post office</attribute>
  79. <!-- The datasource used by the post office to access it's binding information -->
  80. <attribute name="DataSource">java:/DefaultDS</attribute>
  81. <!-- If true will attempt to create tables and indexes on every start-up -->
  82. <attribute name="CreateTablesOnStartup">true</attribute>
  83. <attribute name="SqlProperties"><![CDATA[
  84. CREATE_POSTOFFICE_TABLE=CREATE TABLE JBM_POSTOFFICE (POSTOFFICE_NAME VARCHAR2(255), NODE_ID INTEGER, QUEUE_NAME VARCHAR2(255), COND VARCHAR2(1023), SELECTOR VARCHAR2(1023), CHANNEL_ID INTEGER, CLUSTERED CHAR(1), ALL_NODES CHAR(1), PRIMARY KEY(POSTOFFICE_NAME, NODE_ID, QUEUE_NAME))
  85. INSERT_BINDING=INSERT INTO JBM_POSTOFFICE (POSTOFFICE_NAME, NODE_ID, QUEUE_NAME, COND, SELECTOR, CHANNEL_ID, CLUSTERED, ALL_NODES) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
  86. DELETE_BINDING=DELETE FROM JBM_POSTOFFICE WHERE POSTOFFICE_NAME=? AND NODE_ID=? AND QUEUE_NAME=?
  87. LOAD_BINDINGS=SELECT QUEUE_NAME, COND, SELECTOR, CHANNEL_ID, CLUSTERED, ALL_NODES FROM JBM_POSTOFFICE WHERE POSTOFFICE_NAME=? AND NODE_ID=?
  88. ]]></attribute>
  89. <!-- This post office is non clustered. If you want a clustered post office then set to true -->
  90. <attribute name="Clustered">false</attribute>
  91. <!-- All the remaining properties only have to be specified if the post office is clustered.You can safely comment them out if your post office is non clustered -->
  92. <!-- The JGroups group name that the post office will use -->
  93. <attribute name="GroupName">${jboss.messaging.groupname:MessagingPostOffice}</attribute>
  94. <!-- Max time to wait for state to arrive when the post office joins the cluster -->
  95. <attribute name="StateTimeout">30000</attribute>
  96. <!-- Max time to wait for a synchronous call to node members using the MessageDispatcher -->
  97. <attribute name="CastTimeout">30000</attribute>
  98. <!-- Set this to true if you want failover of connections to occur when a node is shut down -->
  99. <attribute name="FailoverOnNodeLeave">false</attribute>
  100. <depends optional-attribute-name="ChannelFactoryName">jboss.jgroups:service=ChannelFactory</depends>
  101. <attribute name="ControlChannelName">jbm-control</attribute>
  102. <attribute name="DataChannelName">jbm-data</attribute>
  103. <attribute name="ChannelPartitionName">${jboss.partition.name:DefaultPartition}-JMS</attribute>
  104. </mbean>
  105. <!-- Messaging JMS User Manager MBean config======================================= -->
  106. <mbean code="org.jboss.jms.server.plugin.JDBCJMSUserManagerService" name="jboss.messaging:service=JMSUserManager" xmbean-dd="xmdesc/JMSUserManager-xmbean.xml">
  107. <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
  108. <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
  109. <attribute name="DataSource">java:/DefaultDS</attribute>
  110. <attribute name="CreateTablesOnStartup">true</attribute>
  111. <attribute name="SqlProperties"><![CDATA[
  112. CREATE_USER_TABLE=CREATE TABLE JBM_USER (USER_ID VARCHAR2(32) NOT NULL, PASSWD VARCHAR2(32) NOT NULL, CLIENTID VARCHAR2(128), PRIMARY KEY(USER_ID))
  113. CREATE_ROLE_TABLE=CREATE TABLE JBM_ROLE (ROLE_ID VARCHAR2(32) NOT NULL, USER_ID VARCHAR2(32) NOT NULL, PRIMARY KEY(USER_ID, ROLE_ID))
  114. SELECT_PRECONF_CLIENTID=SELECT CLIENTID FROM JBM_USER WHERE USER_ID=?
  115. POPULATE.TABLES.1  = INSERT INTO JBM_USER (USER_ID, PASSWD) VALUES ('guest', 'guest')
  116. POPULATE.TABLES.2  = INSERT INTO JBM_USER (USER_ID, PASSWD) VALUES ('j2ee', 'j2ee')
  117. POPULATE.TABLES.3  = INSERT INTO JBM_USER (USER_ID, PASSWD, CLIENTID) VALUES ('john', 'needle','DurableSubscriberExample')
  118. POPULATE.TABLES.4  = INSERT INTO JBM_USER (USER_ID, PASSWD) VALUES ('nobody', 'nobody')
  119. POPULATE.TABLES.5  = INSERT INTO JBM_USER (USER_ID, PASSWD) VALUES ('dynsub', 'dynsub')
  120. POPULATE.TABLES.6  = INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('guest','guest')
  121. POPULATE.TABLES.7  = INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('j2ee','guest')
  122. POPULATE.TABLES.8  = INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('john','guest')
  123. POPULATE.TABLES.9  = INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('subscriber','john')
  124. POPULATE.TABLES.10 = INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('publisher','john')
  125. POPULATE.TABLES.11 = INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('publisher','dynsub')
  126. POPULATE.TABLES.12 = INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('durpublisher','john')
  127. POPULATE.TABLES.13 = INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('durpublisher','dynsub')
  128. POPULATE.TABLES.14 = INSERT INTO JBM_ROLE (ROLE_ID, USER_ID) VALUES ('noacc','nobody')
  129. ]]></attribute>
  130. </mbean>
  131. </server>

Open \conf\login-config.xml and add these lines


  1. <application-policy name = "messaging">
  2. <authentication>
  3. <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required" >
  4. <module-option name = "unauthenticatedIdentity">guest</module-option>
  5. <module-option name = "dsJndiName">java:/jdbc/ProfilesDS</module-option>
  6. <module-option name = "principalsQuery">
  7. SELECT PASSWD FROM JBM_USER WHERE  USER_ID=?
  8. </module-option>
  9. <module-option name = "rolesQuery">
  10. SELECT ROLE_ID, 'Roles' FROM JBM_ROLE WHERE USER_ID=?
  11. </module-option>
  12. </login-module>
  13. </authentication>
  14. </application-policy>

Installing & Running PHP in Tomcat

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

Here are steps to install and run php in tomcat server.

  1. Download and install latest java from Oracle http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Set java_home in system classpath
  3. Download latest tomcat from “http://tomcat.apache.org/download-70.cgi” and unzip c:\tomcat
  4. Download latest php for window “http://windows.php.net/download/”and unzip to a directory, 
    c:\php
  5. Set path in you system  for php folder like
    path=%path%;c:\php
  6. Download latest PECL Win32 binaries from http://museum.php.net/php5/  like download  “pecl-5.2.5-Win32.zip”
  7. Download latest  PHP-JAVA Bridge war file from http://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_6.2.1/
  8. Go to you php installation folder c:\php and rename “php.ini-production” file to “php.ini” file
  9. Add the new line (If does not exist) in new php.ini:
    ;extension=php_java.dll
  10. Copy php5servlet.dll from PECL 5.2.5 to c:\php
  11. copy php_java.dll from PECL 5.2.5 to 
    c:\php\ext
  12. Copy downloaded ” JavaBridgeTemplate621.war” to tomcat\webapps folder and rename as php.war
  13. Now start tomcat and access you php-java bridge application and test your php file “http://localhost:8080/php/
  14. If you are creating any php file it should go in tomcat\webapps\php\ folder

If you are getting  Error “Could not start FCGI server: java.io.IOException: PHP not found. Please install php-cgi” then MSVCR110.dll is missing from your system. Please install  Visual C++ library from Microsoft website “http://www.microsoft.com/en-us/download/confirmation.aspx?id=30679”. Make sure you download and install the x86 version not 64bit version

Conversion MS office to PDF through open source

Rajnish Kumar
Follow me

Rajnish Kumar

Enabling APIs, IOT (Internet Of Things), Artificial Intelligence ecosystem to our customer and latest technology trend. Worked with our client over 20 years in Project Management, Architecture of Enterprise application and application development .
Extensively worked on IOT, Microservices, APIs,SOA application, Cloud, Amazon AWS,Big Data, Analytics, Artificial intelligence and Security.
Rajnish Kumar
Follow me

Latest posts by Rajnish Kumar (see all)

There is always challenge to convert Microsoft office document to PDF document through open source. I had also some issue when I was working one of the projects and converting Microsoft word doc or Microsoft power point document  to pdf document through open source. Here are some steps to convert Microsoft word document or Microsoft power point document to pdf document through Java application and open source.

Prerequisite Requirements for conversion
1.)    JDK(1.5+)
2.)    Open office version-2.02+(Download from “http://www.openoffice.org/”)
3.)    jodconverter2.2.2 (Download from “http://sourceforge.net/projects/jodconverter/files/”)

Here are steps:-

1.)    install JDK(1.5+) and Open office version-2.02 in your local machine.
2.)    Go to <Open office  install folder>/ program/  folder
3.)    Run this command through MS dos window.

soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

4.)    Now write the given java code and run

  1. import java.io.File;
  2. import com.artofsolving.jodconverter.DocumentConverter;
  3. import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
  4. import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
  5. import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
  6. public class MsDocToPdfUtil {
  7. public static void convertDocToPdf(){
  8. try {
  9. File in = new File("C:/test.doc");
  10. OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
  11. connection.connect();
  12. DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
  13. File outPutFile = new File("C:/test.pdf");
  14. converter.convert(in,outPutFile);
  15. connection.disconnect();
  16. }catch(Exception ex){
  17. ex.printStackTrace();
  18. }
  19. }
  20. public static void main(String[] args) {
  21. try {
  22. convertDocToPdf();
  23. } catch (Exception ex) {
  24. ex.printStackTrace();
  25. }
  26. }
  27. }