JMS unable to consume message from oracle queue

I have to asynchronously push some files in from my system A to system B. For that i have created a JMS Consumer. Once Entries are made in queue successfully using an enqueue stored procedure in oracle. My consumer should read the message and send it to system B.

Here is my Listeners Code

public class DMSCustomMessageListener extends DefaultMessageListenerContainer{
      protected MessageConsumer createConsumer(Session session, Destination destination)
        throws JMSException
      {
        return ((AQjmsSession)session).createConsumer(destination, 
          getMessageSelector(), 
          DMS_Master_Type.getORADataFactory(), null, isPubSubNoLocal());
      }
}


public class DMSListener implements FactoryBean{
      private ConnectionFactory connectionFactory;
      private String queueName;
      private String queueUser;

      @Required
      public void setConnectionFactory(QueueConnectionFactory connectionFactory)
      {
        System.out.println("set connection");
        this.connectionFactory = connectionFactory;
      }
      @Required
      public void setQueueName(String queueName) {
        System.out.println("set DMS listener queuename");
        this.queueName = queueName;
      }
      @Required
      public void setQueueUser(String queueUser) {
        System.out.println("set DMS listener queueuser");
        this.queueUser = queueUser;
      }

      public Object getObject() throws Exception
      {
        QueueConnectionFactory qconn = (QueueConnectionFactory)this.connectionFactory;
        AQjmsSession session = (AQjmsSession)qconn.createQueueConnection("score", "score").createQueueSession(true, 0);
        return session.getQueue(this.queueUser, this.queueName);
      }

      public Class getObjectType()
      {
        return Queue.class;
      }

      public boolean isSingleton() {
        return false;
      }
}

Here is how i configured it.

<bean id="messageDMSListener" class="com.test.DMSTextListener">
</bean>
<bean id="testDMS" class="com.test.DMSListener">
    <property name="connectionFactory" ref="aqConnectionFactoryRspm"/>
    <property name="queueName" value="RSPM_PEND_REQ_Q_DMS"/>    
    <property name="queueUser" value="score"/>
</bean>
<bean id="jmsDMSContainer" class="com.test.DMSCustomMessageListener">
    <property name="connectionFactory" ref="aqConnectionFactoryRspm"/>
    <property name="destination" ref="testDMS"/>
    <property name="messageListener" ref="messageDMSListener" />
    <property name="sessionTransacted" value="true"/>
    <property name="errorHandler" ref="listenerErrorHandler"/>   
</bean>

In my queue table/view (AQ$RSPM_PEND_REQ_Q_DMS) i am gettting expiration reason as 'MAX_RETRY_EXCEEDED' . I have configured it to 10.

What can be the possible reason ? Kindly help.


Oracle Database Queue System differs from the common JMS system so does the way talk to it. I assume you can talk with your queue but the messages do not disappear form the queue but expire instead. If that's the case then I think your queue is configured as "multi user" type. In such occasion it won't disappear until all recipients get the message and the queue owner is also the recipient. As you just want to pass the message to another system reconfigure your queue to single user and the message disappear immediately after reading.

As a matter of fact you don't need your java bean either. You can do the job by configuring queue propagation(and the corresponding job) straight in the database without any external objects (example skeleton below is not complete solution):

BEGIN
DBMS_AQADM.SCHEDULE_PROPAGATION (
   queue_name         => 'init_queue',
   destination        => NULL,
   start_time         => SYSDATE,
   duration           => NULL,
   next_time          => NULL,
   latency            => 60,
   destination_queue  => 'dest_queue');
END;
链接地址: http://www.djcxy.com/p/76424.html

上一篇: 模拟消息进入异常队列的场景

下一篇: JMS无法使用oracle队列中的消息