Post Subject : Tutorial on J2EE using JBOSS-4.x, Eclipse-3.x, Lomboz-3.x and PostgreSQL-8.x on Windows XP
Ref. 1 : Tutorial for building J2EE Applications using JBOSS and ECLIPSE http://www.tusc.com.au/tutorial/html/chap7.html (Chapter 7 : Message Driven Bean) Ref. 2 : Tutorial on J2EE using JBOSS, ECLIPSE and Lomboz (Forum on Ref. 1) http://www.jboss.org/index.html?module=bb&op=viewtopic&t=36910 Ref. 3 : Environment in use ; - Windows XP SP2 - J2SDK 1.4.2_08 - Eclipse 3.0.2 - JBoss 4.0.2 - Lomboz 3.0.1 + emf-sdo-runtime-2.0.0 - PostgreSQL 8.0.3 (= DefaultDS) Followings are some notes on Chapter 7 (MDB) in Ref. 1 * The notes cover a creation of RequestItemsBean. * Task numbers are based on Ref. 1 * No change has been made to the server definition file (jboss402postgres.server) thus far. * Copy and paste additional files for Chapter 7 and after. - Before start up JBoss, copy and paste three "*.xml" files below. Keep their contents as they are. a. "hajndi-jms-ds.xml" and "file-state-service.xml" in /jboss-4.0.2/docs/examples/jms to "/postgres/deploy-hasingleton/jms" b. "jbossmq-state.xml" in /jboss-4.0.2/docs/examples/jms/conf to "/postgres/conf" - As a result, "/postgres/deploy-hasingleton/jms" folder contains following files. jbossmq-httpil.sar file-state-service.xml hajndi-jms-ds.xml jbossmq-destinations-service.xml jbossmq-service.xml jvm-il-service.xml oil-service.xml postgres-jdbc3-service.xml rmi-il-service.xml uil2-service.xml =Note : All other settings and files are kept unchanged after Chapter 6. For addition of "file-state-service.xml", see Step 8 (Modify the JBoss Login Config File) in the first post of this thread. Task 1 : Create RequestItems MDB under package au.com.tusc.mdb - On creation of "ItemBean", check some points before proceeding further steps. = make sure the XDoclet parts of ItemBean.java; : | * <!-- begin-xdoclet-definition --> * @ejb.bean name="RequestItems" * acknowledge-mode="Auto-acknowledge" | * destination-type="javax.jms.Queue" * subscription-durability="NonDurable" * transaction-type="Container" | * | : Task 2 : Create an Immutable Value Object named RequestItem. - On creation of "RequestItem", confirm a point below. : | public class RequestItem extends java.lang.Object implements Serializable { | : Task 3 : Implement the onMessage method (as per the steps in Ref. 1) Task 4 : Deploy the RequestItems Bean (add some deployment descriptors as per the steps in Ref. 1) - generate EJB classes - fix deployment descriptions, i.e. "ejb-local-ref" and "ejb/" - confirm copy-and-paste of additional three files. (see Note above) - start JBoss with "Run Server" menu in "Lomboz J2EE View" tag. - if failure/error messages occur, stop JBoss and check the tables in the database with "pgAdmin III". - drop all of following files if exist. hilosequences jms_message_log jms_reference_log jms_transaction_log timers - re-start JBoss Task 5 : Create a test client name RequestMDBClient : (as per the steps in Ref. 1) Task 6 : Add a method named testMDBBean Task 7 : Run the test client and test the bean - Messages expected in the console are;Looking up the factory | Looking up the queue | Creating the connection now ... | Creating the session now ... | Creating the sender now ... | Setting the object in message now ... | Sending the message | Shutting down | Finishedbut, they might be as follows instead, which are a summary of "server.log". 23:37:03,906 INFO [STDOUT] Message Driven Bean got message org.jboss.mq.SpyObjectMessage { | Header { | jmsDestination : QUEUE.MdbQueue | jmsDeliveryMode : 2 | jmsExpiration : 0 | jmsPriority : 4 | jmsMessageID : ID:9-11188462238901 | jmsTimeStamp : 1118846223890 | jmsCorrelationID: null | jmsReplyTo : null | jmsType : null | jmsRedelivered : false | jmsProperties : {} | jmsPropReadWrite: false | msgReadOnly : true | producerClientId: ID:9 | } | } | 23:37:03,906 INFO [STDOUT] Entering RequestItemsBean.onMessage() | 23:37:03,968 INFO [STDOUT] Entering StoreAccessBean | 23:37:03,968 INFO [STDOUT] Leaving StoreAccessBean | 23:37:03,968 INFO [STDOUT] Entering StoreAccessDAOImpl.loginUser() | 23:37:03,984 INFO [STDOUT] Userid is U6 | 23:37:03,984 INFO [STDOUT] Leaving StoreAccessDAOImpl.loginUser() | 23:37:03,984 INFO [STDOUT] Entering StoreAccessBean.getItemData() | 23:37:03,984 INFO [STDOUT] Entering ItemBean.getItemData() | 23:37:03,984 INFO [STDOUT] Leaving ItemBean.getItemData() | 23:37:03,984 INFO [STDOUT] Entering ItemBean.getItemData() | 23:37:03,984 INFO [STDOUT] Leaving ItemBean.getItemData() | 23:37:03,984 INFO [STDOUT] Leaving StoreAccessBean.getItemsOutOfStock() | 23:37:04,000 INFO [STDOUT] List of Out-Of-Stock Items | 23:37:04,015 INFO [STDOUT] Entering SupplierBean.requestItem() 30 | 23:37:04,015 INFO [STDOUT] Leaving SupplierBean.requestItem() | 23:37:04,015 INFO [STDOUT] Entering SupplierBean.requestItem() 30 | 23:37:04,015 INFO [STDOUT] Leaving SupplierBean.requestItem() | 23:37:04,015 INFO [STDOUT] Leaving RequestItemsBean.onMessage() - Also, the results can be checked in the database table using "pgAdmin III". = select * from supplier ==> "S1";"U4";"SEBASTIAN";"BELLOFIORE";"10 ELIZABETH ST";"I430";0.00 === On completion of RequestItemsBean, the contents of <message-driven> tag of each file are as follows; - ejb-jar.xml : | <!-- Message Driven Beans --> | <message-driven > | <description><![CDATA[<!-- begin-user-doc --> You can insert your documentation for '<em><b>RequestItemsBean</b></em>'.]]></description> | | <ejb-name>RequestItems</ejb-name> | | <ejb-class>au.com.tusc.mdb.RequestItemsBean</ejb-class> | <transaction-type>Container</transaction-type> | <acknowledge-mode>Auto-acknowledge</acknowledge-mode> | <message-driven-destination> | <destination-type>javax.jms.Queue</destination-type> | <subscription-durability>NonDurable</subscription-durability> | </message-driven-destination> | | <ejb-ref > | <ejb-ref-name>ejb/StoreAccess</ejb-ref-name> | <ejb-ref-type>Session</ejb-ref-type> | <home>au.com.tusc.session.StoreAccessHome</home> | <remote>au.com.tusc.session.StoreAccess</remote> | <ejb-link>StoreAccess</ejb-link> | </ejb-ref> | | <ejb-local-ref > | <ejb-ref-name>ejb/SupplierLocal</ejb-ref-name> | <ejb-ref-type>Entity</ejb-ref-type> | <local-home>au.com.tusc.cmp.SupplierLocalHome</local-home> | <local>au.com.tusc.cmp.SupplierLocal</local> | <ejb-link>Supplier</ejb-link> | </ejb-local-ref> | | </message-driven> | : - jboss.xml : | <message-driven> | <ejb-name>RequestItems</ejb-name> | <destination-jndi-name>queue/MdbQueue</destination-jndi-name> | <ejb-local-ref> | <ejb-ref-name>ejb/SupplierLocal</ejb-ref-name> | <jndi-name>SupplierLocal</jndi-name> | </ejb-local-ref> | <ejb-ref> | <ejb-ref-name>ejb/StoreAccess</ejb-ref-name> | <jndi-name>StoreAccessBean</jndi-name> | </ejb-ref> | </message-driven> | : jbosszone View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3881772#3881772 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3881772 ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user