[jboss-user] [JBossMQ] - MDB with Oracle AQ via Sun Adapter

ryandavid do-not-reply at jboss.com
Mon Feb 23 06:00:01 EST 2009


I have integrated Oracle AQ with JBoss 4.0.2 using the rar of Sun Adapter. I can send messages to a queue but I have some problems in using an MDB that reads from a queue.

The MDB is BMT because the adapater doesn't support XA connections.

I used this ejb-jar.xml

<ejb-jar>
  | <enterprise-beans>
  | 
  | 	<message-driven>
  | 		<ejb-name>TestJMSBean</ejb-name>
  | 		<ejb-class>it.senato.testjms.TestJMSBean</ejb-class>
  |         <messaging-type>javax.jms.MessageListener</messaging-type>        
  |         <transaction-type>Bean</transaction-type>
  | 
  |         <activation-config>
  |               <activation-config-property>
  |                  <activation-config-property-name>destinationType</activation-config-property-name>
  |                  <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
  |               </activation-config-property>
  | 
  | 
  |             <activation-config-property>
  |                 <activation-config-property-name>destinationProperties</activation-config-property-name>
  |                 <activation-config-property-value>owner=senaprod,name=FROM_QUEUE</activation-config-property-value>
  |              </activation-config-property>
  |             <activation-config-property>
  |                 <activation-config-property-name>connectionFactoryProperties</activation-config-property-name>
  |                 <activation-config-property-value>jdbc_connect_string=jdbc:oracle:thin:scott/mypass at myhost:1521:svil,host=senadbmssvil,user=scott,password=mypass,port=1521,sid=svil,driver=thin</activation-config-property-value>
  |              </activation-config-property>
  | 
  |             <activation-config-property>
  |                 <activation-config-property-name>userName</activation-config-property-name>
  |                 <activation-config-property-value>scott</activation-config-property-value>
  |              </activation-config-property>
  |             <activation-config-property>
  |                 <activation-config-property-name>mypass</activation-config-property-name>
  |                 <activation-config-property-value>svil</activation-config-property-value>
  |              </activation-config-property>
  | 
  |            </activation-config>
  |            
  |     </message-driven>
  | 
  |   </enterprise-beans>
  | 
  |     <assembly-descriptor>
  |     </assembly-descriptor>
  | 
  | </ejb-jar>

this jboss.xml

<jboss>
  | 	<enterprise-beans>
  | 		
  | 	    <message-driven>
  |            <ejb-name>TestJMSBean</ejb-name>
  | 
  |             <invoker-bindings>
  |               <invoker>
  |                 <invoker-proxy-binding-name>message-inflow-driven-bean</invoker-proxy-binding-name>
  |               </invoker>
  |             </invoker-bindings>
  | 
  |             <resource-adapter-name>oracleaq.rar</resource-adapter-name>
  | 
  |        </message-driven>
  |     </enterprise-beans>
  | </jboss>
  | 

and finally this is the onMessage() method


  | 	public void onMessage(Message msg) {
  |         try {
  |             ctx.getUserTransaction().begin();
  | 
  |             logger.debug("onMessage...");
  |             // extract message
  |             TextMessage textMessage = null;
  |             try {
  |                 textMessage = (TextMessage) msg;
  | 
  |             } catch (ClassCastException ce) {
  |                 logger.warn("Received a non TextMessage");
  |                 ctx.getUserTransaction().commit();
  |                 return;
  |             }
  | 
  |             logger.info("Received a text message: " + textMessage.getText());
  |             msg.acknowledge();
  |             ctx.getUserTransaction().commit();
  | 
  |         } catch (NotSupportedException e) {
  |             logger.error(e.getMessage(),e);
  |         } catch (SystemException e) {
  |             logger.error(e.getMessage(),e);
  |         } catch (JMSException e) {
  | 			logger.error(e.getMessage(),e);
  |         } catch (RollbackException e) {
  |             logger.error(e.getMessage(),e);
  |         } catch (HeuristicMixedException e) {
  |             logger.error(e.getMessage(),e);
  |         } catch (HeuristicRollbackException e) {
  |             logger.error(e.getMessage(),e);
  |         }
  | 
  |     }
  | 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212206#4212206

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212206



More information about the jboss-user mailing list