Sunday, June 21, 2020

WSO2 Micro Integrator- Remove Request Headers From Response

Add the name of the header to be removed as a property property

<property name="<name of the header to be removed>" scope="transport" action="remove"/>

Note : The above method removes only the specified headers from the response. If you need to remove all the headers, follow the instructions below.
Add the TRANSPORT_HEADERS property

<property name="TRANSPORT_HEADERS" action="remove" scope="axis2"/>

WSO2 Micro Integrator - Enable Jms transport

Edit file [MI_HOME]/conf/deployment.toml, add below lines:
[[transport.jms.listener]]
name = "myQueueListener"
parameter.initial_naming_factory = "com.ibm.mq.jms.context.WMQInitialContextFactory"
parameter.broker_name = "IBM MQ"
parameter.provider_url = "X.X.X.X:1416/Channel"
parameter.connection_factory_name = "connection_factory_name "
parameter.connection_factory_type = "queue"



[[transport.jms.sender]]
name = "myQueueSender"
parameter.initial_naming_factory = "com.ibm.mq.jms.context.WMQInitialContextFactory"
parameter.broker_name = "IBM MQ"
parameter.provider_url = "X.X.X.X:1416/Channel"
parameter.connection_factory_name = "connection_factory_name "
parameter.connection_factory_type = "queue"


Copying IBM Websphere MQ libraries

These instructions are tested on IBM WebSphere MQ version 8.0.0.4. However, you can follow them for other versions appropriately.
  • Create a new directory named wmq-client , and then create another new directory named lib inside it.
  • Copy the following JAR files from the <IBM_MQ_HOME>/java/lib/ directory (where <IBM_MQ_HOME> refers to the IBM WebSphere MQ installation directory) to the wmq-client/lib/ directory.
com.ibm.mq.allclient.jar
mqcontext.jar
jms.jar
providerutil.jar
  • Create a POM.xml file inside the wmq -client/ directory and add all the required dependencies as shown in the example below.
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>wmq-client</groupId>
<artifactId>wmq-client</artifactId>
<version>8.0.0.4</version>
<packaging>bundle</packaging>
<dependencies>
    <dependency>
        <groupId>com.ibm</groupId>
        <artifactId>fscontext</artifactId>
        <version>8.0.0.4</version>
        <scope>system</scope>
        <systemPath>${basedir}/lib/mqcontext.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>com.ibm</groupId>
        <artifactId>providerutil</artifactId>
        <version>8.0.0.4</version>
        <scope>system</scope>
        <systemPath>${basedir}/lib/providerutil.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>com.ibm</groupId>
        <artifactId>allclient</artifactId>
        <version>8.0.0.4</version>
        <scope>system</scope>
        <systemPath>${basedir}/lib/com.ibm.mq.allclient.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>javax.jms</groupId>
        <artifactId>jms</artifactId>
        <version>1.1</version>
        <scope>system</scope>
        <systemPath>${basedir}/lib/jms.jar</systemPath>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.4</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Name>${project.artifactId}</Bundle-Name>
                    <Export-Package>*;-split-package:=merge-first</Export-Package>
                    <Private-Package/>
                    <Import-Package/>
                    <Embed-Dependency>*;scope=system;inline=true</Embed-Dependency>
                    <DynamicImport-Package>*</DynamicImport-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>
  • Navigate to the wmq -client directory using your Command Line Interface (CLI), and execute the following command, to build the project: mvn clean install
  • Stop the WSO2 Micro Integrator, if it is already running.
  • Remove any existing IBM MQ client JAR files from the MI_HOME/dropins directory and the MI_HOME/lib directory.
  • Copy the <wmq-client>/target/wmq-client-8.0.0.4.jar file to the MI_HOME/dropins directory.
  • Download the jta.jar file from the maven repository, and copy it to the MI_HOME/lib directory.
Reference: https://ei.docs.wso2.com/en/7.1.0/micro-integrator/setup/brokers/configure-with-IBM-websphereMQ

Sunday, June 14, 2020

JBOSS 7.3 connect to remote ActiveMQ


  1. Create mododule ActiveMQ
    mkdir -pv $JBOSS_HOME/modules/system/layers/base/org/apache/activemq/main
    cp activemq-all-5.15.9.jar $JBOSS_HOME/modules/system/layers/base/org/apache/activemq/main
    Create module.xml with content below:
    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.5" name="org.apache.activemq">
       <resources>
            <resource-root path="activemq-all-5.15.9.jar"/>
        </resources>
        <dependencies>
            <module name="javax.api"/>
            <module name="javax.jms.api"/>
        </dependencies>
    </module>
  2. Choose "Configuration -> Naming -> Binding" click Add(external-context)
    Class: javax.naming.InitialContext
    Environment:
    java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
    java.naming.provider.url=tcp://xxxxx:61616
    Module: org.apache.activemq
    Name: java:global/remoteContext
    Binding Type: external-context
  3. Choose "Configuration -> Naming -> Binding" click Add(lookup) for ConnectionFactory, Queue,..
    Binding Type: lookup
    Lookup: java:global/remoteContext/ConnectionFactory

Monday, June 1, 2020

JMS Message as a MQRFH2 Message

MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = CMQC.MQGMO_PROPERTIES_FORCE_MQRFH2 + CMQC.MQGMO_FAIL_IF_QUIESCING + CMQC.MQGMO_NO_WAIT;
MQMessage receiveMsg = new MQMessage();
queue.get(receiveMsg, gmo);
if (CMQC.MQFMT_RF_HEADER_2.equals(receiveMsg.format)){
   receiveMsg.seek(0);
   byte[] b = new byte[receiveMsg.getMessageLength()];
   DataInputStream inputStream =  new DataInputStream(new ByteArrayInputStream(b));
   MQRFH2 rfh2 = new MQRFH2(inputStream );
   int strucLen = rfh2.getStrucLength();
   int encoding = rfh2.getEncoding();
   int CCSID    = rfh2.getCodedCharSetId();
   String format= rfh2.getFormat();
   int flags    = rfh2.getFlags();
   int nameValueCCSID = rfh2.getNameValueCCSID();
   String[] folderStrings = rfh2.getFolderStrings();
   for (String folder : folderStrings)
      System.out.println("Folder: "+folder);
      b = new byte[inputStream.available()];
      inputStream.read(b);
      System.out.println("Data: "+new String(b));
}else if (CMQC.MQFMT_STRING.equals(receiveMsg.format)){
   String msgStr = receiveMsg.readStringOfByteLength(receiveMsg.getMessageLength());
   System.out.println("Data: "+msgStr);
}else{
   byte[] b = new byte[receiveMsg.getMessageLength()];
   receiveMsg.readFully(b);
   System.out.println("Data: "+new String(b));
}

Friday, May 8, 2020

Redhat fuse - JMS for IBM MQ

Drap and drop the JMS componet


In properties of the JMS component, select tab Advance and input the connect  Factory( the connection factory have to begin with # . Ex: #connectionFactory)

Add com.ibm.mq.allclient.jar to classpath( com.ibm.mq.allclient.jar is provided by IBM MQ).

Click to tab Configuration and add 1 bean with same name for Connection Factory( ex: connectionFactory).


The JBOSS EAP must run with  standalone-full.xml profile.

Rehat fuse - JDBC

Drap and drop JDBC component to Design tab
Input URI: jdbc:[datasource] ex: ExampleDS
Click to tab Configuration and add 1 bean with name is datasource name( ex: ExampleDS).

Tuesday, March 10, 2020

IBM Integration Bus - When you write Java™ code for a JavaCompute node, you can include references to other Java projects and JAR files.

To complete this task, you must have completed the following tasks:
  • Add a JavaCompute node to your message flow.
  • Create Java code for a JavaCompute node.
The Java code in a JavaCompute node might contain references to other Java projects in the Eclipse workspace (internal dependencies), or to external JAR files, for example the JavaMail API (external dependencies), or a set of JAXB Java object classes (internal or external). If other JAR files are referenced, you must add the files to the project class path.
See Using JAXB with a JavaCompute node for an example of a project using Java objects generated by the JAXB binding compiler.
  1. Right-click the project folder for the project on which you are working, and click Properties.
  2. Click Java Build Path in the left pane.
  3. Click the Libraries tab.
  4. Complete one of the following steps:
    • To add an internal dependency, click Add JARs, select the JAR file that you want to add, then click OK.
    • To add an external dependency, click Add External JARs, select the JAR file that you want to add, then click Open. Copy the JAR file to the shared-classes directory required. For more details of the shared-classes directories available and the effects of each, see Java shared classloader. If you do not copy the JAR file to a valid shared-classes directory, ClassNotFoundException exceptions are generated at run time.
You have now added a code dependency.

Reference: https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ac30280_.htm

Loads all the JAR files located within the shared-classes directories.

Loads all the JAR files located within the shared-classes directories. The precedence order of loading is dictated by the directories the JAR files are located in.

Determine the integration node workpath to use by running the mqsireportbroker command as follows:

mqsireportbroker integrationNodeName

JAR files are loaded in the following precedence order:
  • For Windows
    • workpath\config\<my_int_node_name>\<my_int_server_label>\shared-classes
  • For Linux, UNIX, and z/OS
    • workpath/config/<my_int_node_name>/<my_int_server_label>/shared-classes
  • For Windows
    • workpath\config\<my_int_node_name>\shared-classes
  • For Linux, UNIX, and z/OS
    • workpath/config/<my_int_node_name>/shared-classes
  • For Windows
    • workpath\shared-classes
  • For Linux, UNIX and z/OS
    • workpath/shared-classes

Install and use xorg-server on macOS via Homebrew

  The instructions to install and use xorg-server on macOS via Homebrew: Install Homebrew (if you haven't already): /bin/bash -c ...