0 Replies Latest reply on Feb 25, 2009 8:58 AM by ryandavid

    MDB with Oracle AQ via Sun Adapter

    ryandavid

      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

      Code:

      <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@myhost:1521:svil,host=senadbmssvil,user=scott,pass
      word=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

      Code:

      <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

      Code:

      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);
       }
      
       }
      




      When I deploy this MDB, it reads the first message that's in the queue and prints out the text.
      The other messages are deleted from the queue but their texts aren't printed out.
      In addition the sender send's a message but nothing happens: no message in the queue and no printing out.

      It seems as the MDB is locking the queue.