Thursday, 21 May 2009

6-How to Develop Message-Driven Beans

Weblogic JMS setup follows:

For deploying EJB:
You first run ANT in the MDBentity directory – namely you run the build.xml
You have the output in the C:\MDBentity\deploy directory.
You select Deployments in the Domain Structure section on the left…
You select install and it goes on from there….
If you can not do this, please refere to my WLST script tha you can find in the other EJB entries
in this blog.

To define the JMS:
Select Services in the Domain Structure Section on the left…
Select messaging
Select JMS Servers
Select new Name:styejbJMS target:DefaultServer


DO NOT PLAY WITH THE PARAMETERS – Use MINIMUM CHANGES.

To define the Topic:
Select Services in the Domain Structure Section on the left…
Select messaging
Select JMS Modules
Select new
Name:OrderVerifierARS
Summary of Resources: Name:OrderVerifierTopic JNDIName:OrderVerifierTopic
SubDeployment: styejbJMS

WARNING: 1- I had some problems in running the example. It seemed as if onMessage did not work… Also, as if, I must start the MDB manually just after the DefaultServer startup??? But at the end it worked without really being aware of how it happened really. I also changed to
String connectionFactoryJndiName = "weblogic.jms.ConnectionFactory"; from the older
javax.jms.TopicConnectionFactory…

2- Playing with the console setups related to logging can be helpful in seeing more information in the logs.
The System.out.println commands in the EJBs are printed into the Running - server log which you can switch to from the Running - application log simply at the bottom right section of the Jdev.

3- There is also the monitoring options at the top of the DefaultDomain – Deployments window.
You can select your EJB and select monitoring and see its status – very useful.

The outputs of the logs follows:
Default Server LOG

<May 21, 2009 2:59:50 PM EEST> <Notice> <Stdout> <BEA-000000> <setEntityContext called>
<May 21, 2009 2:59:50 PM EEST> <Notice> <Stdout> <BEA-000000> <ejbPostCreate() called.>
<May 21, 2009 2:59:50 PM EEST> <Notice> <Stdout> <BEA-000000> <ejbCreate() called.>
<May 21, 2009 2:59:50 PM EEST> <Notice> <Stdout> <BEA-000000> <ejbStore() called.>
<May 21, 2009 2:59:51 PM EEST> <Notice> <Stdout> <BEA-000000> <ejbLoad() called.>
<May 21, 2009 2:59:51 PM EEST> <Notice> <Stdout> <BEA-000000> <ejbStore() called.>
<May 21, 2009 2:59:51 PM EEST> <Notice> <Stdout> <BEA-000000> <************ Order Information ************>
<May 21, 2009 2:59:51 PM EEST> <Notice> <Stdout> <BEA-000000> <****ARSSSSSSSSSSssssssss Order Id is : 1242907190421>
<May 21, 2009 2:59:51 PM EEST> <Notice> <Stdout> <BEA-000000> <************ Order Information Ends ************>
<May 21, 2009 2:59:56 PM EEST> <Notice> <Stdout> <BEA-000000> <ejbLoad() called.>
<May 21, 2009 2:59:56 PM EEST> <Notice> <Stdout> <BEA-000000> <ejbStore() called.>
<May 21, 2009 3:00:56 PM EEST> <Error> <JDBC> <BEA-001112> <Test "select count(*) from SYSTABLES" set up for pool "myJDBCDataSource" failed with exception: "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'testars.systables' doesn't exist".>
<May 21, 2009 3:00:56 PM EEST> <Info> <JDBC> <BEA-001128> <Connection for pool "myJDBCDataSource" closed.>
<May 21, 2009 3:00:57 PM EEST> <Info> <JDBC> <BEA-001067> <Connection for pool "myJDBCDataSource" refreshed.>


Running mdbex.jpr log
C:\Oracle\Middleware\jdk160_05\bin\javaw.exe -client -classpath C:\JDeveloper\mywork\EJB3\MDBex\classes;C:\JDeveloper\mywork\EJB3\lib\wlfullclient5.jar Client
Starting Client . . .
Looking up the JMS destination(Topic) via JNDI.
Locating connection factory.
Creating a connection and establishing a session.
Creating an order with status:Submitted
Order id 1242908873140 is created
Creating a text message with order id and publishing it.
Sleeping for 5 sec.
Now the order status is:Verified
Process exited with exit code 0.