Today I have to configure IBM ODM Events so that the SunJDK can send messages to it. There's a few steps. I'll be working mainly in the Rules Designer. And this first part just shows how to get a JMS client talking to ODM in with the IBMJDK.
Let's assume that you have ODM with the Events components installed on C:\IBM\ODM85. And that you have created an ODM profile in the folder <ODM Install>/profiles/ODMSamples8500. I am using version 8.5, but this should work with previous versions of ODM / WODM with some obvious changes to pathnames, filenames, etc. Likewise, it doesn't have to be SamplesServer.
Even though I'm not going to use it yet, I'll need to install the SunJDK as an alternate JRE in Eclipse. So I downloaded the SunJDK only and installed that in C:\Java. Then in Eclipse Windows/Preferences menu, filter on Installed JRE. and from there add the new Java install dir.
Then I'll need a client JMS project in Eclipse, so change to the Java perspective and create a new Java project. Call it JMSClientExample.
Create some security configuration folders. In the Eclipse project create a new folder. Call it security. Under it create two more folders, one called properties and one called etc.
Copy the trust.p12 and key.p12 files from your <ODM Profile>/etc folder in to the new etc folder.
To do this, from the project inspector, right click on the etc folder and select Import... File System and then browse to the <ODM profile>/etc folder and select those files.
Likewise, copy the ssl.client.props and sas.client.props files from your <ODM Profile>/properties folder in to the new properties folder. To do this, right click on the properties folder and select Import... File System and then browse to the <ODM profile>/properties folder and select those files.
Edit the ssl.client.props file and change the user.root to point to your current project/security folder. To do this right click on the project security folder that you created and select properties. This will give you the full path to the folder. Highlight the path and use ctrl-c to copy. Then ctrl-s to save the file.
Edit the sas.client.props file and set the following:
com.ibm.CORBA.securityServerPort to your correct port, by default it is 2809.
com.ibm.CORBA.loginSource=properties
com.ibm.CORBA.loginUserid=admin and set
com.ibm.CORBA.loginPassword=admin
(Assuming admin/admin for authentication to the SamplesServer)
In project properties, (right click on project, find properties in the menu), go to the Java Builder tab. Add the j2ee.jar as an External Jars from the <ODM Install Dir>/lib folder.
Create a new class in the project. Call it JMSClientExample.java and add the following source code:
import java.util.Hashtable;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
public class JMSClientExample {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String messageID = null;
String outString = null;
String cfName = "jms/WbeConnectionFactory";
String qnameIn = "jms/actionTopic";
String qnameOut = "jms/actionTopic";
boolean verbose = false;
Session session = null;
Connection connection = null;
ConnectionFactory cf = null;
MessageProducer mp = null;
Destination destination = null;
try {
Hashtable env = new Properties();
env.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2811"); // change your port as appropriate, default is 2809
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
Context initialContext = new InitialContext(env);
System.out.println("Getting Connection Factory");
cf= (ConnectionFactory)initialContext.lookup( cfName );
System.out.println("Getting Queue");
destination =(Destination)initialContext.lookup(qnameOut);
System.out.println("Getting Connection for Queue");
connection = cf.createConnection("admin","admin"); // use the createConnection method that takes auth params
System.out.println("staring the connection");
connection.start();
System.out.println("creating session");
session = connection.createSession(false, 1);
System.out.println("creating messageProducer");
mp = session.createProducer(destination);
System.out.println("creating TextMessage");
TextMessage outMessage = session.createTextMessage("this is test application");
System.out.println("sending Message");
mp.send(outMessage);
mp.close();
session.close();
connection.close();
}
catch (Exception je) {je.printStackTrace();}
}
}
Now set the runtime debug properties.
Create a debug configuration for JMSClientExample. In the VM Arguments add the following:
-Dcom.ibm.CORBA.Debug=true
-Dcom.ibm.CORBA.CommTrace=true
-Dcom.ibm.CORBA.Debug.Output=c:/temp/client.log
-Dcom.ibm.ejs.ras.lite.traceSpecification=*=all
-Dcom.ibm.SSL.ConfigURL=file:///${project_loc}/security/properties/ssl.client.props
-Dcom.ibm.CORBA.ConfigURL=file:///${project_loc}/security/properties/sas.client.props
-Dcom.ibm.ejs.ras.lite.traceSpecification=SIB*=all
-Dcom.ibm.ejs.ras.lite.traceFileName=c:/temp/trace.log
Add the following to the classpath from the <ODM Install Dir>/runtimes folder.
com.ibm.ws.ejb.thinclient_8.5.0.jar,
com.ibm.ws.orb_8.5.0.jar,
com.ibm.ws.sib.client.thin.jms_8.5.0.jar.
And from the <ODM Install Dir>/runtimes/properties folder add the
orb.properties file.
orb.properties is not a jar file so you'll have to change the file selector to *.* in order to add it. These files provide the runtime elements you need to talk to the WAS JMS provider in IBM ODM.
com.ibm.ws.orb_8.5.0.jar,
com.ibm.ws.sib.client.thin.jms_8.5.0.jar.
And from the <ODM Install Dir>/runtimes/properties folder add the
orb.properties file.
orb.properties is not a jar file so you'll have to change the file selector to *.* in order to add it. These files provide the runtime elements you need to talk to the WAS JMS provider in IBM ODM.
At this point, you should be able to run this app without errors using just the IBM JDK. Next we're going to switch over to the SunJDK.
This comment has been removed by the author.
ReplyDeleteIt is very nice & useful......
ReplyDeleteAgility Insight