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

Sunday, March 1, 2020

IBM Integration Bus - Filter Node

Filter Node
The “Filter” node is the simplest of the routing nodes and provides a simple “If-Then-Else” routing mechanism within a Message Flow. The “Filter” node is an ESQL node. The ESQL executed in this node must terminate with an ESQL RETURN statement. This statement must return a Boolean value. The route taken from this node depends upon the value of the RETURN statement.
This node has four output terminals. These terminals are:

  •  Failure (A failure in the ESQL code)
  • True (ESQL code returns a “True” value)
  • False (ESQL code returns a “False” value)
  • Unknown (ESQL code returns a “NULL” value or does not “RETURN” a boolean)
Note: The “Filter” node propagates an unchanged input message to an output terminal. If you are referring to the input message to interrogate its contents in a Database or Filter node, use correlation name Body to refer to the start of the message. Body is equivalent to Root followed by the parser name (for example, Root.XMLNS), which you can use if you prefer. You cannot use the Body correlation name in a DatabaseInput node.
You must use these different correlation names because there is only one message to which to refer in a Database or Filter node; you cannot create an output message in these nodes. Use a Compute node to create an output message.


Example:

CREATE FILTER MODULE HTTPInputMessageFlow_Filter
    CREATE FUNCTION Main() RETURNS BOOLEAN
    BEGIN
        
        DECLARE space1 NAMESPACE 'namespace1';
        IF Body.space1:root.space1:example = 'ABCDE' THEN
            RETURN TRUE;
        ELSE
            RETURN FALSE;
        END IF;
    END;
END MODULE;



Wednesday, February 26, 2020

IBM Integration Bus- DFDL in ESQL

To parse  binary to XML in ESQL:

CREATE LASTCHILD OF OutputRoot DOMAIN('DFDL') PARSE(binaryData ENCODING InputRoot.Properties.Encoding TYPE '{Namespace}:RootElement');

To convert XML to binanry in ESQL:
We have to prepare the DFDL in OutputRoot like:

CREATE LASTCHILD OF OutputRoot DOMAIN('DFDL') NAME 'DFDL';
DECLARE ns NAMESPACE 'Namespace';
SET OutputRoot.DFDL.Namespace:RootElement=...

The Output is auto convert to binary
DECLARE bPayload BLOB ASBITSTREAM(InputRoot.DFDL.HRRecords CCSID InputRoot.Properties.CodedCharSetId ENCODING InputRoot.Properties.Encoding);

IBM Integration Bus - Working with MQ ( request and response with same correlId).

We have the service via couple queue, We send request to Input Queue and get the response from Out Queue with the same correlId.
The code for "set message to queue" compute node
CREATE COMPUTE MODULE HTTPInputMessageFlow_set_message_to_queue
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();
SET OutputRoot.BLOB.BLOB = InputRoot.BLOB.BLOB;

RETURN TRUE;
END;

CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;

CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;

The code for "set correlId" compute node
CREATE COMPUTE MODULE HTTPInputMessageFlow_set_correlId
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();
SET OutputRoot.MQMD.CorrelId = InputLocalEnvironment.WrittenDestination.MQ.DestinationData.correlId;

RETURN TRUE;
END;

CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;

CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;

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 ...