SOA / Web Services / Java

A Technology Blog

Archive for July, 2014

Continous Integration Tools: Which one is the best?

Posted by Vivek on July 28, 2014

Here is a snapshot of the survey conducted by infoQ on their site to figure out which continuous integration tools is widely used and has got the desired features:

CI_Tools

 

 

Posted in SOA | Leave a Comment »

Java based integration framework

Posted by Vivek on July 8, 2014

We all know the capabilities of an ESB to enable seamless integration among hetrogeneous applications. But is it always a feasible to choose an ESB where integration is not a major challenge and where applications use common protocols? The answer is NO. Most of the companies are looking for open source options which allows them build an integration architecture using simple configuration. Two of the most commonly used frameworks are:

1. Spring Integration

  • Based on popular Spring application framework
  • Dependency Injection / Inversion of Control
  • Configured within Spring Container
  • XML / Annotation based DSL
  • Supports Spring expression language

 

2. Apache Camel

  • Apache Software Foundation project
  • Custom Container – Camel Context
  • Can be instantiated directly from Java method
  • Integration with Spring, Guice, OSGI

Posted in SOA | Tagged: , , , , | Leave a Comment »

Purge messages from queue using Groovy/ Java

Posted by Vivek on July 8, 2014

Purging messages is one of the common operations when working with queues.

MQI (Message Queue Interface) allows browsing/ reading the message by providing various calls (MQGET, MQOPEN etc) and options alongwith. Below is a sample code to traverse the messages in a queue and perform destructive read.

 

// Set the Get Message Options

int getOpenOpts1 = MQC.MQOO_INQUIRE + MQC.MQOO_BROWSE + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INPUT_SHARED

MQGetMessageOptions gmo1 = new MQGetMessageOptions();

gmo1.options = MQC.MQGMO_BROWSE_FIRST + MQC.MQGMO_NO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_ACCEPT_TRUNCATED_MSG;

boolean msgPresent = true

while(msgPresent){

try{  

                def getMsg1 = new MQMessage();                     

                getQ1.get(getMsg1, gmo1);

                gmo1.options = MQC.MQGMO_MSG_UNDER_CURSOR    

                getQ1.get(getMsg1, gmo1);

gmo1.options = MQC.MQGMO_BROWSE_NEXT + MQC.MQGMO_NO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_ACCEPT_TRUNCATED_MSG;                        

   }

   catch(MQException e){

if (e.completionCode == 1 && e.reasonCode == MQException.MQRC_TRUNCATED_MSG_ACCEPTED)

             {

                 // Same as expected

             }

             else

             {                 

               msgPresent = false;

             }

   }          

  }

Posted in Groovy, IBM Websphere MQ, Java/J2EE | Tagged: , , | 1 Comment »

Using SOAPUi to put/get message in/from IBM MQ

Posted by Vivek on July 8, 2014

We can use HermesJMS which provides out of the box feature to communicate with any of the messaging system. It comes with both soapUI open source and pro version. However, the drawback is message will contain JMS header and the responsibility of converting JMS to native header format lies with the developer/ tester. I have used IBM MQ as messaging system and in order to avoid any transformation from JMS to MQMD, I have used groovy to put and read messages.

Add a groovy test step to get hold of the XML message to be sent

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )

def holder = groovyUtils.getXmlHolder(“AddDiscussionBoardItem#Request”)

log.info holder.getXml()

def xml = holder.getXml()

//Connect to the queue manager

// Queue used for putting message

def propIQueue = testRunner.testCase.getProperty(“inputqueue”)

//Queue used for reading message

def propOQueue = testRunner.testCase.getProperty(“outputqueue”)

 //setting hostname

def propHostname = testRunner.testCase.getProperty(“hostname”) 

MQEnvironment.@hostname = propHostname.getValue()

 //setting port

def propPort = testRunner.testCase.getProperty(“port”)

MQEnvironment.@port = Integer.parseInt(propPort.getValue())                       

//setting Channel

def propChannel = testRunner.testCase.getProperty(“channel”)

MQEnvironment.@channel = propChannel.getValue()        

//setting Queue Manager

def propQM = testRunner.testCase.getProperty(“queuemanager”)

def queueManager = new MQQueueManager(propQM.getValue())

//Put message in queue

 def putMsg = new MQMessage();

int putOpenOpts = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;

def putQ = queueManager1.accessQueue(propIQueue.getValue(), putOpenOpts);

putMsg.writeString(xml);

def pmo = new MQPutMessageOptions();

putQ.put(putMsg, pmo);

putQ.close()

//Read message from queue

def getMsg = new MQMessage();

int getOpenOpts = MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST;

MQGetMessageOptions gmo=new MQGetMessageOptions();

def getQ = queueManager1.accessQueue(propOQueue.getValue(), getOpenOpts);

getQ.get(getMsg, gmo);

def response = getMsg.readString(getMsg.getMessageLength())

getQ.close()

Posted in Groovy, IBM Websphere Message Broker, IBM Websphere MQ | Tagged: , , | 1 Comment »

Deploying BAR (Broker Archive) using ANT

Posted by Vivek on July 7, 2014

This is not very straight-forward. WMB provide mqsideploy script to deploy the BAR file but before invoking the script, you need to source the mqsiprofile batch file. mqsiprofile is not a perl script and cannot be invoked directly. On windows platform, it is present in MQSI_Home/bin folder as a batch command file (.bat). This batch file has to run before mqsideploy.exe within the same script. Create a new batch command file (deploywmb.cmd) and add the following lines:

 

CALL “C:\Program Files\IBM\MQSI\7.0\bin\mqsiprofile.cmd”

CALL C:\Progra~1\IBM\MQSI\7.0\bin\mqsideploy.exe -i %1 -p %2 -q %3 -b %4 -e%5 -a %6

 

Where,

%1 corresponds to ipaddress, %2 corresponds to port and so on and are passed from Ant script.

The batch file is called and arguments are passed from Ant script as follows:

<target name=”deploy-bar”>

<property file=”${basedir}/build-properties/config/${Env}/DEMO.properties”/>

<property name=”bar-location” value=”${basedir}//bars//${Env}_${bar.file}.bar”/>

<echo message=”MQSI Deploy “></echo>

<exec executable=”C:\utilities\wmbbuild\deploywmb.cmd”

spawn=”false”

logError=”true”

vmlauncher=”false”

failonerror=”true”

append=”true”>

<arg value=”${ipaddress}” />

<arg value=”${port}” />

<arg value=”${queuemgr}” />

<arg value=”${broker}” />

<arg value=”${exegroup}” />

<arg path=”${bar-location}” />

</exec>

<echo message=”Deploying Broker Archive file – ${bar.name} ” />

</target>

Where,

${Env} is the environment for which BAR is created. Example – Dev, test, UAT

DEMO.properties file is the file for storing environment specific properties. The following properties are read from DEMO.properties file:

${ipaddress} is the name of the host of the Queue Manager

${port} is the port number of the listener

${queuemgr} is the Queue Manager name of the broker

${broker} is the broker name whose execution group is to be used for deployment

${exegroup} is the name of the execution group

${bar-location} is the location of BAR file which needs to get deployed

Posted in IBM Websphere Message Broker, IBM Websphere MQ, integration | Tagged: , , , , | Leave a Comment »

MQ JARs – Build and Deployment

Posted by Vivek on July 7, 2014

We miss most of the jars in the classpath that give classnotfoundexception during operations related to WMB. Here is the list of jars required in MQ library to enable build and deployment of message flows on execution group:

com.ibm.mq.commonservices.jar

brokerutil.jar

com.ibm.mq.headers.jar

com.ibm.mq.jar

com.ibm.mq.jmqi.jar

com.ibm.mq.pcf.jar

ConfigManagerProxy.jar

connector.jar

Posted in IBM Websphere Message Broker, IBM Websphere MQ | Leave a Comment »

MQOPEN options while reading/browsing MQ messages

Posted by Vivek on July 7, 2014

When using MQI, it is almost a possibility to read and browse messages. MQOPEN call precedes before accessing the messages and it is important to provide correct options before you do something with the messages.
For the options of the MQOPEN call:
v At least one of the following must be specified:
– MQOO_BROWSE
– MQOO_INPUT_AS_Q_DEF
– MQOO_INPUT_EXCLUSIVE
– MQOO_INPUT_SHARED
– MQOO_INQUIRE
– MQOO_OUTPUT
– MQOO_SET
v Only one of the following is allowed:
– MQOO_INPUT_AS_Q_DEF
– MQOO_INPUT_EXCLUSIVE
– MQOO_INPUT_SHARED
v Only one of the following is allowed:
– MQOO_BIND_ON_OPEN
– MQOO_BIND_NOT_FIXED
– MQOO_BIND_AS_Q_DEF

Posted in IBM Websphere MQ, integration | Tagged: | Leave a Comment »