3 Replies Latest reply on Nov 25, 2005 4:34 AM by Rudi Vankeirsbilck

    whne DLQ is full

    Ramesh Newbie



      In order to capture the messages during exceptions we have used DLQ. we have implemented MDBs to subscribe for messages. when the DLQ reaches its maximum limit, the container (JBoss) goes into a loop posting for the message. we found that it is due to the fact that DLQ reaches its maximum depth and is not able to accommodate additional messages.

      So I would like to know how to make the container stop posting for the message once the dead letter queue (DLQ) reaches its maximum depth.

      If you have any better suggestions to overcome this problem please advise me.

        • 1. Re: whne DLQ is full
          Rudi Vankeirsbilck Newbie

          I think you should first look at why the messages are going to the DLQ. Once you have solved the exceptions that you are getting in your MDBs, your messages will no longer go to the DLQ and hence you will have solved this problem.

          • 2. Re: whne DLQ is full
            Ramesh Newbie

            Hi Rudi
            thans for your suggestion,
            our motive is we should not loose messages even when any exceptions comes, so we implemented DLQ.
            everything is working fine but we have a problem when DLQ is full.
            Can u suggest what to when DLQ is full?

            • 3. Re: whne DLQ is full
              Rudi Vankeirsbilck Newbie

              Hmmm, I am guessing there is a setting that you could change to increase the size of the DLQ but have not found it yet.

              On the other hand, the DLQ is just another queue that you can subscribe to. I have created an MDB that picks up new messages that go to the DLQ and transfers them to a DB. A log is created so application engineers can come in and find all the relevant data of the message and debug the problem with the real data.

              ejb-jar.xml (generated with xdoclet):

               <message-driven id="MessageDriven_15">
               <description><![CDATA[Implements the component that will subscribe to the dead letter queue provided by the app server.]]></description>
               <ejb-name>DeadLetterQueueSubscriber</ejb-name>
               <ejb-class>com.bluespace.core.implementation.events.subscribers.dlq.DeadLetterQueueSubscriber</ejb-class>
              
               <messaging-type>javax.jms.MessageListener</messaging-type>
               <transaction-type>Container</transaction-type>
               <message-destination-type>javax.jms.Queue</message-destination-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>acknowledgeMode</activation-config-property-name>
               <activation-config-property-value>Auto-acknowledge</activation-config-property-value>
               </activation-config-property>
               <activation-config-property>
               <activation-config-property-name>subscriptionDurability</activation-config-property-name>
               <activation-config-property-value>Durable</activation-config-property-value>
               </activation-config-property>
               </activation-config>
               <env-entry>
               <env-entry-name>jms/QueueConnectionFactoryName</env-entry-name>
               <env-entry-type>java.lang.String</env-entry-type>
               <env-entry-value><![CDATA[ConnectionFactory]]></env-entry-value>
               </env-entry>
               <resource-ref id="ResRef_15">
               <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
               <res-type>javax.jms.QueueConnectionFactory</res-type>
               <res-auth>Container</res-auth>
               </resource-ref>
               </message-driven>
              


              jboss.xml:
               <message-driven>
               <ejb-name>DeadLetterQueueSubscriber</ejb-name>
               <destination-jndi-name>queue/DLQ</destination-jndi-name>
               <mdb-client-id>DeadLetterQueueSubscriber</mdb-client-id>
               <mdb-subscription-id>DeadLetterQueueSubscriber</mdb-subscription-id>
               <resource-ref>
               <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
               <jndi-name>ConnectionFactory</jndi-name>
               </resource-ref>
               </message-driven>
              


              java code:
              public class DeadLetterQueueSubscriber extends BlueSpaceSubscriber {
              /* Methods for constructing new instances. */
               public DeadLetterQueueSubscriber() {
               super();
               }
              
              /* Keep out! */
              /* Constants */
               /* None at this time */
              
              /* Methods for handling messages. */
               protected void onMessage (ObjectMessage message) throws NamingException, JMSException, Exception {
               Serializable messageObject = message.getObject();
               if (messageObject instanceof BlueSpaceEvent) {
               BusinessContext businessContext = new BusinessContext();
               try {
               BlueSpaceEvent event = (BlueSpaceEvent) messageObject;
               Logger.DLQ.debug("Receiving event from native dead letter queue.");
               Logger.DLQ.debug(event);
               this.moveToDeadLetterQueue(businessContext, message, event);
               }
               finally {
               try {
               businessContext.close();
               }
               catch (BlueSpaceResourceManagementException e) {
               Logger.DLQ.error(e);
               }
               }
               }
               else {
               Logger.DLQ.error(new Object[] {"MDB ", this.getClass().getName(), " is receiving object message of type ", messageObject.getClass().getName(), " but was expecting com.bluespace.core.interfaces.events.abstracts.BlueSpaceEvent"});
               }
               }
              
               protected void onMessage (BusinessContext businessContext, BlueSpaceEvent event) throws Exception {
               /* No implementation required, will not be called as this class overrides onMessage(ObjectMessage). */
               }
              
               /**
               * Moves a {@link javax.jms.Message Message} containing a {@link BlueSpaceEvent BlueSpaceEvent} that was delivered too many times
               * to the dead letter queue.<br>
               * It will transform the BlueSpaceEvent to a {@link com.bluespace.core.implementation.events.dlq.DeadLetter DeadLetter}
               * and write that straight into the database, using immediate access to a {@link com.bluespace.core.persistence.tools.sql.StoredProcedure StoredProcedure}.
               * This may break development guidelines and software engineering principles because we break the layering
               * but it does reduce the risk of not being able to persist the DeadLetter.<br>
               * If that still fails, the transaction will be marked for rollback and the message will be returned to the JMS engine one more time.
               * The JMS engine should be configured thus that the redelivery is set to be 1 bigger than the BlueSpace TransMail System maximum redelivery setting.
               * This way, when the Message is once again returned to the JMS engine, the latter will transfer it to its own dead letter queue.
               *
               * @param businessContext
               * @param message
               * @param event
               */
               protected void moveToDeadLetterQueue (BusinessContext businessContext, Message message, BlueSpaceEvent event) {
               try {
               if (Logger.DLQ.isInfoEnabled()) {
               Logger.DLQ.info(
               new Object[] {
               "Moving ",
               event,
               " from native dead letter queue to the real dead letter queue"});
               }
               CreateDeadLetter deadLetterCreator = new CreateDeadLetter(new DeadLetter(message.getJMSMessageID(), event, this.getClass(), -1));
               deadLetterCreator.execute(businessContext, this.getDataSourceLocator().getSystemDataSource());
               }
               catch (NamingException e) {
               Logger.DLQ.error(e);
               Logger.DLQ.error("Error while getting datasource to persist a BlueSpaceEvent to the dead letter queue.\nCommitting transaction anyway to avoid looping here.", e);
               }
               catch (JMSException e) {
               Logger.DLQ.error(e);
               Logger.DLQ.error("Error while getting information to persist a BlueSpaceEvent to the dead letter queue.\nCommitting transaction anyway to avoid looping here.", e);
               }
               catch (IOException e) {
               Logger.DLQ.error(e);
               Logger.DLQ.error("Error while getting information to persist a BlueSpaceEvent to the dead letter queue.\nCommitting transaction anyway to avoid looping here.", e);
               }
               catch (PersistenceException e) {
               Logger.DLQ.error(e);
               Logger.DLQ.error("Error while persisting a BlueSpaceEvent to the dead letter queue.\nCommitting transaction anyway to avoid looping here.", e);
               }
               catch (Throwable e) {
               Logger.DLQ.error(e);
               Logger.DLQ.error("General error while persisting a BlueSpaceEvent to the dead letter queue.\nCommitting transaction anyway to avoid looping here.", e);
               }
               }
              
              /* Class variables */
               /* None at this time */
              /* Instance variables */
               /* None at this time */
              }
              


              The CreateDeadLetter component is a java wrapper around an oracle stored procedure.

              Hope this helps for you.