IBM Rational Software Architect 7.0 with embedded WebSphere Application Server 6.1.
Purpose:
- Create a JMS client application to send a simple message to a queue defined by WAS 6.1 default messaging provider.
- Create a MDB to consume the message received by the queue.
- Open RSA, use the New wizard to create an Enterprise Application Project under J2EE group, if you cannot see this selection, check if you are using the J2EE perspective. I called the project minzy.
- Click "Show Runtimes" to make sure the v6.1 is selected.
- Click "New Modules" to create default modules, check off Web module and Connector module, which we don't need, and change the name of the EJB module to minzyEnt. It's only my preference, you can call it any name.
- Rename source folders to "src" in both minzyClient and minzyEnt.
- In minzyClient, create a package "tliu.minzy.client" and create a class "MessProducer" with main method.
- Delete default package.
- Edit MANIFEST.MF under META-INF and change Main-Class to tliu.minzy.client.MessProducer.
- From menu Project, select clean and select minzyClient, minzyEnt and minzy, error in minzy and minzyClient will be gone.
- In minzyEnt, create package tliu.minzy.ent, use New wizard to create a Enterprise Bean.
- Check "Message-driven bean", give name MessConsumer, select package tliu.minzy.ent and check on "Generate an annotated bean class".
- Make sure JMS type is javax.jms.MessageListener.
- Check off "Add bean to Class Diagram", diagrams are out of the scope.
- Now you see all error gone, we are ready to put real codes in.
public static void main(String[] args) throws Exception {Code in MessConsumerBean:
InitialContext initCtx = new InitialContext();
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup("jms/minzyConnectionFactory");
Destination q = (Destination) initCtx.lookup("jms/minzyQueue");
Connection connection = qcf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer queueSender = session.createProducer(q);
TextMessage outMessage = session.createTextMessage();
outMessage.setText("Hello, minzy.");
outMessage.setJMSType("minzy");
outMessage.setJMSDestination(q);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
queueSender.send(outMessage);
connection.close();
System.out.println("Minzy mess produced.");
}
public void onMessage(javax.jms.Message mess) {Packaging:
TextMessage text = (TextMessage) mess;
try {
System.out.println("Message Received: " + text.getText());
} catch (JMSException e) {
System.out.println("Oops, exception.");
}
}
Export minzyClient to C:\development\applications\minzyClient.ear.
Export minzyEnt to C:\development\applications\minzyEnt.ear.
Deployment:
- In Servers view in RSA, select WebSphere Application Server v6.1 and start the server.
- After started, right click the server and select "Run administrative console".
- Navigate Service integration > Buses > New and create a bus "minzyBus".
- Navigate minzyBus > Bus members > Add and add server "cledt-123691Node02:server1".
- Open a command window, and change directory to "C:\Program Files\IBM\SDP70\runtimes\base_v61\bin", run "setupCmdLine.bat".
- Run "wsadmin -f installSdoRepository.jacl -createDb cledt-123691Node02 server1".
- Verify SDO Repository successfully started under Enterprise Applications. Note, install once per server.
- Run "wsadmin -f ../util/sibwsInstall.jacl INSTALL_RA -installRoot "C:/Program Files/IBM/SDP70/runtimes/base_v61" -nodeName cledt-123691Node02". Note, install once per node.
- Run "wsadmin -f ../util/sibwsInstall.jacl INSTALL -installRoot "C:/Program Files/IBM/SDP70/runtimes/base_v61" -serverName server1 -nodeName cledt-123691Node02".
- Run "wsadmin -f ../util/sibwsInstall.jacl INSTALL_HTTP -installRoot "C:/Program Files/IBM/SDP70/runtimes/base_v61" -serverName server1 -nodeName cledt-123691Node02".
- In the admin console, navigate to Servers > Application Servers > server1 > Endpoint Listeners and select New. Specify SOAPHTTPChannel1 as name, http://cledt-123691.agna.amgreetings.com:9081/SOAPHTTPChannel1 as URL root, http://cledt-123691.agna.amgreetings.com:9081/sibws as WSDL root.
- Select the "Connection Properties" of SOAPHTTPChannel1, client New and select minzyBus.
- Go to minzyBus > Destinations, there should be a new destination called cledt-123691Node02.server1.SOAPHTTPChannel1Reply.
- Navigate minzyBus > Destinations > New and create a Queue type destination "minzyDestination".
- Navigate Resources > JMS Providers > Default messaging. Select Node as the scope.
- Select Connection factories and click New. Enter minzyConnectionFactory as name, jms/minzyConnectionFactory as JNDI name, select minzyBus, enter localhost:7277 in the "Provider endpoints" box, leave other default and click OK.
- Go back to Default messaging provider and select Queues. Click New.
- Enter minzyQueue as name, jms/minzyQueue as JNDI name, select minzyBus and minzyDestination. Click OK.
- Go back to Default messaging provider and select Activation specifications. Click New.
- Enter minzyActivation as name, eis/minzyActivation as JNDI name, jms/minzyQueue as Destination JNDI name and select minzyBus. Click OK and save all your changes.
- Install minzyEnt.ear in admin console. Make sure Deploy enterprise beans are checked. Enter eis/minzyActivation as Activation Specification Target and jms/minzyQueue as Destination.
- Restart server.
In a command line window, change directory to C:\Program Files\IBM\SDP70\runtimes\base_v61\bin. Run,
setupCmdLine.bat
launchClient \development\applications\minzyClient.ear -CCBootstrapPort=2810
In the command line window, you shall see,
WSCL0014I: Invoking the Application Client class tliu.minzy.client.MessProducer
Minzy mess produced.
In the server console, you shall see,
[8/6/07 13:33:32:455 EDT] 0000002f SystemOut O Message Received: Hello, minzy.
The End.
2 comments:
To drug and drop application minzy in workbench to WAS 6.1 under Servers view and get deployed, open the Deployment Descriptor of minzyEnt, go to tab Bean, select MessConsumer, then go the WebSphere Bindings section, select JCA Adapter, enter eis/minzyActivation for ActivationSpec JNDI name, jms/minzyQueue for Destination JNDI name, save and redeploy.
Good Morning!!! j2eeinaction.blogspot.com is one of the most outstanding innovative websites of its kind. I enjoy reading it every day. I will be back.
Post a Comment