Monday, 27 June 2016

UDP(User Defined Properties in Message Broker)


UDP
..............

1.If we specified in the message flow's User defined properties panel some values like dsn,schema then in the flow we need to declare using 'EXTERNAL' keyword & give some null values within single quotes.The values that we mention in the ESQL code are not effected with the values in the Message flow User defined properties panel.

Ex:- DECLARE cDATABASE EXTERNAL CHARACTER '';

2. No need to create UDP in flow but using ESQL coding we can create UDP

Ex:-DECLARE cDATABASE EXTERNAL CHARACTER 'EAI';

How to delete a broker that is creating trouble to delete?


1. C:\ProgramData\IBM\MQSI


       There remove the Broker name in the Common,Config,registry folders

2. Queue Manager Deletion in Win 7
     C:\Program Files (x86)\IBM\WebSphere MQ\Qmgrs

Deleting Brokers path in Windows 7

C:\Program Files (x86)\IBM\WebSphere MQ\Qmgrs
C:\ProgramData\IBM\MQSI\components


Another case is when we change the System Password also,Broker does not start & connect to queue manager.In that case goto Run-->Services.msc & make sure that three of them are in started state or else delete the broker & queue manager using the above steps & create a new broker using Default Configuration wizard.




Now change the password here also to the newly changed password



Sunday, 20 March 2016



MS Outlook 2013 Issue which has Unread messages 


Question:- I have an annoying problem in Outlook 2013. My inbox is flagged with "1" unread message, but this is not the case. Even when I empty my inbox folder, this bold "1" stays next to my folder, new as it contains a new message.I've tried to "empty" it, to "clean" it, to "mark all as read" it. Nothing works.


Solution:-

In the “Search Current Mailbox (Ctrl+E)” box, type: read:no and hit Enter.
When it shows “Find More on Server” link, click it. Then the unread email(s) should appear.
EDIT: Works with Outlook 2016 as well.

Friday, 19 February 2016


           Using the Exception plug-in node in IIB V9.0



Introduction
The Exception plug-in node requires IBM® Integration Bus V9 or later, and runs on both
Microsoft® Windows® and Linux®. The plug-in node consists of two parts, a run-time JAR file
(
ExceptionRuntime.jar), and a design-time Toolkit plug-in (ExceptionJavaPlugin.jar), which
provide the node for use in message flows.

Installing
To install the run-time component:
1.
Download ExceptionPlugin.zip at the bottom of the article.
2. Unzip ExceptionPlugin.zip.
3. Copy
runtime/ExceptionRuntime.jar to all of the machines running brokers that are required
to run the node. Place the JAR file in
<IBM Integration Bus Runtime Install Directory>/
plugins
:
• Windows:
C:\Program Files (x86)\IBM\MQSI\9.0.0.0\jplugin
• Linux: /opt/ibm/mqsi/9.0.0.1/jplugin
To install the design-time component:
1. Unzip the plug-in zip file.
2. Copy
toolkit/ExceptionJavaPlugin.jar and place in <IBM Integration Bus
Toolkit Install Directory>/plugins
. For example: C:\Program Files (x86)\IBM
\IntegrationToolkit90\plugins
.
developerWorks® ibm.com/developerWorks/
Using the Exception plug-in node in IBM Integration Bus Page 2 of 7

Uninstalling
1. Stop IBM Integration Bus and close the Toolkit.
2. Remove the runtime JAR file
ExceptionRuntime.jar from the <IBM Integration Bus Install
Directory>/plugin
directory.
3. Remove the toolkit JAR file
ExceptionJavaPlugin.jar from the <IBM Integration Bus
Toolkit Directory>/plugins
directory.
4. Start IBM Integration Bus and open the Toolkit.

How the node works
The Exception node parses the ExceptionTree generated during message flow execution, and
retrieves details such as Exception Code, Text, and Details. The following example shows how you
can use the node in a message flow:





In this message flow,
HTTPRequest throws a socket exception, and the Exception node retrevies the
generated exception details.
Here is the flow execution in Debug mode. Before the Exception node:
After the Exception node. The Exception details are captured in
Enviornment.
ibm.com/developerWorks/ developerWorks®
Using the Exception plug-in node in IBM Integration Bus Page 3 of 7


Conclusion
IBM Integration Bus Exception node makes it much easier to capture exception details in a
message flow, and avoids redundant code that you must reconfigure for every project.

                          Sequence Node in Message Broker


Step 1:- Create a flow with MQInput Node,Sequence Node & MQOutput Node as follows


Step 2:- Sequence Node configuration


Step 3:- Provide the input like this :-
<doc><grp>AJAY</grp></doc>

Step 4:- The result would be like this on first run
<doc><grp>AJAY</grp><seq>0</seq></doc>

Next time you put the same input again,the result would be

<doc><grp>AJAY</grp><seq>1</seq></doc>

The sequence keeps on increasing like this..

Simple flow using JavaCompute Node in Message Broker 


Step 1:- Create a flow with MQInput Node,JavaCompute Node & MQOutput Node as follows.

Step 2:- Then paste the following code into JCN.

import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.MbElement;
import com.ibm.broker.plugin.MbException;
import com.ibm.broker.plugin.MbMessage;
import com.ibm.broker.plugin.MbMessageAssembly;
import com.ibm.broker.plugin.MbOutputTerminal;
import com.ibm.broker.plugin.MbUserException;
public class Java_Compute_Node_JavaCompute extends MbJavaComputeNode {
public void evaluate(MbMessageAssembly inAssembly) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
//MbOutputTerminal alt = getOutputTerminal("alternate");
MbMessage inMessage = inAssembly.getMessage();
MbMessageAssembly outAssembly = null;
try {
// create new message as a copy of the input
MbMessage outMessage = new MbMessage(inMessage);
outAssembly = new MbMessageAssembly(inAssembly, outMessage);
MbElement xml = outAssembly.getMessage().getRootElement().getLastChild();
MbElement emp = xml.getFirstChild();
emp.setName("Student");
MbElement sno = emp.getFirstChild();
sno.setName("sno");
MbElement sname = sno.getNextSibling();
sname.setName("sname");
sname.setValue(sname.getValue().toString().toUpperCase());
out.propagate(outAssembly);
} catch (MbException e) {
// Re-throw to allow Broker handling of MbException
throw e;
} catch (RuntimeException e) {
// Re-throw to allow Broker handling of RuntimeException
throw e;
} catch (Exception e) {
// Consider replacing Exception with type(s) thrown by user code
// Example handling ensures all exceptions are re-thrown to be
// handled in the flow
throw new MbUserException(this, "evaluate()", "", "", e.toString(),
null);
}
// The following should only be changed
// if not propagating message to the 'out' terminal
out.propagate(outAssembly);
}
}


Step 3:- Provide the input as follows:-
<Employee><eno>1</eno><ename>ajay</ename></Employee>

Step 4:- The result would be like 
<Student><sno>1</sno><sname>AJAY</sname></Student>

Saturday, 7 November 2015


A major issue in the WMB message flows is the error handling.I saw many production message flows which loose messages meaning loose business information.WMB platform give the developer freedom and variety of the error handling but it is very important to understand how it works.
So let's start.

You can divide the broker elements in two categories under transactional objects and non transactional. On the transactional objects the engine makes checkpoints before entering each node. Thus if exception thrown in the entered node the object that you will get will be without any changes made in the node. If you need the changed object details you need to catch it in the node (java/esql try catch code). The non transactional elements save their state and the engine don't do any rollback on them.

Transactional Objects (those who have the Input/Output prefix):
  • Body - Root
  • LocalEnvironment
Non transactional :
  • Environment
  • ExceptionList
Node's Failure Terminal:- 
Each node has a failure terminal. Message will route to this terminal only if there was an exception in the node and the failure terminal is connected otherwise the exception will be propagated to the previous up the flow. If an error occurred downstream it won't be routed to the node's failure terminal. I don't recommend using this pattern except maybe when calling sync service like.
When developing sub flows remember to connect all the terminal of the sub flow, because during the deployment of the flow the compiler will neglect the unconnected terminals, thus if failure occurred in the sub flow and you didn't connect it the failure won't be propagated to the main flow and thus you will lose track of the error.

Try Catch pattern and Catch terminal:-
My suggestion is to use this pattern; you get it implicit on the input nodes, by choosing the transaction mode.
Don't forget to throw exception at the end of the catch handling if you working under transaction otherwise no rollback will be executed because the whole transaction handled successfully.
If you developing synchronized service construct indicative reply message for the caller.
Very important if you putting dump messages for logging by the MQOutput set it to non transaction mode, if not your dump message will also be roll backed by the engine and you won't see your message in the queue.
Put your tryCatch node on common business parts, divide your flows wisely.
Trace Nodes

Nice function giving you the ability to dump your trace to log files, trace or custom files. You can dump whatever you want, ${Root}, and use the ESQL function like CURRENT_DATE.
The major improvement in 6.1 version is that now you don't need to delete the trace nodes after the development you can just disable them by this command :

mqsichangetrace –n [on off]

MQInput Node error handling flow when working under transaction (otherwise the message will be discarded) and the error occurred beyond the MQInput node.
  1. If catch terminal connected the exception will be propagated there. Remember to throw custom exception for the Roll back process in which all action against external sources like DB or MQ queues will be back-out.
    It is also a good place for compensation process if needed.
The message will be rolled back to input queue and the back out count will be raised by one.
  1. If failure terminal connected the and the back-out count of the message equals treshold property the message will routed there if not it will be routed to the Back-out queue (property on the input queue) and if it not set then it tries to put it on the Qmgr back out queue.
    if no back out queue exist it will try to put the message on the Qmgr DLQ.
    If error occurred beyond the failure terminal then the engine will try to resend the message twice the treshold number ( new in version 6.1) and then try to put it on the Qmgr Back out Queue and if not then on the Qmgr DLQ.
    If no success yet then the message will loop infinitely thus become a poison message and manual interfering is needed.

Threshold Limit

MQ gives you set of properties by which you can handle back out messages. You can set on the queue the back out number and the back out queue name. the MQInput node will route the message implicitly if the treshold is reached.

                                         Simple Hibernate Application without IDE



Here, we are going to create the first hibernate application without IDE. For creating the first hibernate application, we need to follow following steps:
  1. Create the Persistent class
  2. Create the mapping file for Persistent class
  3. Create the Configuration file
  4. Create the class that retrieves or stores the persistent object
  5. Load the jar file
  6. Run the first hibernate application without IDE
1) Create the Persistent class
A simple Persistent class should follow some rules:
  • A no-arg constructor: It is recommended that you have a default constructor at least package visibility so that hibernate can create the instance of the Persistent class by newInstance() method.
  • Provide an identifier property (optional): It is mapped to the primary key column of the database.
  • Declare getter and setter methods (optional): The Hibernate recognizes the method by getter and setter method names by default.
  • Prefer non-final class: Hibernate uses the concept of proxies, that depends on the persistent class. The application programmer will not be able to use proxies for lazy association fetching.



Let's create the simple Persistent class:

Employee.java

  package com.java.mypackage;  
2     
3public class Employee {  
4private int id;  
5private String firstName,lastName;  
6      
7 public int getId() {  
8     return id;  
9    }  
1 public void setId(int id) {  
1     this.id = id;  
1 }  
1 public String getFirstName() {  
1     return firstName;  
1 }  
1 public void setFirstName(String firstName) {  
1     this.firstName = firstName;  
1 }  
1 public String getLastName() {  
2     return lastName;  
2 }  
2 public void setLastName(String lastName) {  
2     this.lastName = lastName;  
2 }  
2   
2   
2 }  



2) Create the mapping file for Persistent class
The mapping file name conventionally, should be class_name.hbm.xml. There are many elements of the mapping file.
  • hibernate-mapping is the root element in the mapping file.
  • class It is the sub-element of the hibernate-mapping element. It specifies the Persistent class.
  • id It is the subelement of class. It specifies the primary key attribute in the class.
  • generator It is the subelement of id. It is used to generate the primary key. There are many generator classes such as assigned (It is used if id is specified by the user), increment, hilo, sequence, native etc. We will learn all the generator classes later.
  • property It is the subelement of class that specifies the property name of the Persistent class.
Let's see the mapping file for the Employee class:
employee.hbm.xml
1    <?xml version='1.0' encoding='UTF-8'?>  
2    <!DOCTYPE hibernate-mapping PUBLIC  
3     "-//Hibernate/Hibernate Mapping DTD 3.0//EN"  
4     "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">  
5      
6     <hibernate-mapping>  
7      <class name="com.javatpoint.mypackage.Employee" table="emp1000">  
8        <id name="id">  
9         <generator class="assigned"></generator>  
1     </id>  
1             
1     <property name="firstName"></property>  
1     <property name="lastName"></property>  
1             
1   </class>  
1             
1  </hibernate-mapping>  



3.) Create the Configuration file
The configuration file contains informations about the database and mapping file. Conventionally, its name should be hibernate.cfg.xml .
hibernate.cfg.xml
1    <?xml version='1.0' encoding='UTF-8'?>  
2    <!DOCTYPE hibernate-configuration PUBLIC  
3              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"  
4              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">  
5      
6    <hibernate-configuration>  
7      
8        <session-factory>  
9            <property name="hbm2ddl.auto">update</property>  
1         <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>  
1         <property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>  
1         <property name="connection.username">system</property>  
1         <property name="connection.password">oracle</property>  
1         <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>  
1     <mapping resource="employee.hbm.xml"/>  
1     </session-factory>  
1   
1 </hibernate-configuration>  




4) Create the class that retrieves or stores the object
In this class, we are simply storing the employee object to the database.
1    package com.javatpoint.mypackage;  
2      
3    import org.hibernate.Session;  
4    import org.hibernate.SessionFactory;  
5    import org.hibernate.Transaction;  
6    import org.hibernate.cfg.Configuration;  
7      
8    public class StoreData {  
9    public static void main(String[] args) {  
1       
1     //creating configuration object  
1     Configuration cfg=new Configuration();  
1     cfg.configure("hibernate.cfg.xml");//populates the data of the configuration file  
1       
1     //creating seession factory object  
1     SessionFactory factory=cfg.buildSessionFactory();  
1       
1     //creating session object  
1     Session session=factory.openSession();  
2       
2     //creating transaction object  
2     Transaction t=session.beginTransaction();  
2           
2     Employee e1=new Employee();  
2     e1.setId(115);  
2     e1.setFirstName("sonoo");  
2     e1.setLastName("jaiswal");  
2       
2     session.persist(e1);//persisting the object  
3       
3     t.commit();//transaction is commited  
3     session.close();  
3       
3     System.out.println("successfully saved");  
3       
3 }  
3 }  




5) Load the jar file
For successfully running the hibernate application, you should have the hibernate4.jar file.
download the latest hibernate jar file. Some other jar files or packages are required such as
  • cglib
  • log4j
  • commons
  • SLF4J
  • dom4j
  • xalan
  • xerces




6) How to run the first hibernate application without IDE
We may run this hibernate application by IDE (e.g. Eclipse, Myeclipse, Netbeans etc.) or without IDE. We will learn about creating hibernate application in Eclipse IDE in next chapter.
To run the hibernate application without IDE:
  • install the oracle10g for this example.
  • load the jar files for hibernate. (One of the way to load the jar file is copy all the jar files under the JRE/lib/ext folder). It is better to put these jar files inside the public and private JRE both.
  • Now Run the StoreData class by java com.javatpoint.mypackage.StoreData