Skip to Content

Applies To: JDK 1.5 / 1.6, CE 7.3/ 7.4

Author(s):      Biplab Ray

Company:      Tata Consultancy Services

Created on:    12th February 2015

Author Bio:

Biplab Ray is working for Tata Consultancy Services as Assistant Consultant and development of SAP EP, composite applications using CAF, BPM, BRM, WebDynpro for Java. He also works in technologies like Java/J2EE and has depth understanding on eSOA, Webservice, Enterprise Service, XML.

Requirement:

In many case we were facing issue to passing the message via JMS queue of Application server.

In some situation at a single point of time more than 10,000 messages was passing via JMS queue of Application Server java, if due to some error one of the message was not able to pass from the queue then rest of the message would stuck in the queue.

If we restart the application server, even though queue would not getclear, and application server would try to post rest of the message again and would reach to the same situation.

To overcome the situation we have to update the message status from “DLNG” to “FAIL”.

Implementation :


  1. Create one EJB.
  2. Write one business method.
  3. And expose the ejb as web service.

In the class below imports are required :

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.SQLException;

import javax.annotation.Resource;

import javax.sql.DataSource;

For back end connectivity we required Data Source.

Please declare Data Source as below.

@Resource(mappedName = “SAP/CAF_RT”)

DataSource dataSource;

Business method implementation as below

@javax.ejb.TransactionAttribute (javax.ejb.TransactionAttributeType.REQUIRES_NEW)

      public void clear() {

                       try {

                              Connection connection = dataSource.getConnection();

                              PreparedStatement preparedStatement = connection.prepareStatement

(“UPDATE BC_MSG SET STATUS = ? WHERE STATUS = ?”);

                              preparedStatement.setString(1, “FAIL”);

                              preparedStatement.setString(2, “DLNG”);

                              preparedStatement.executeUpdate();

                              preparedStatement.close();

                              connection.close();

                  } catch (SQLException e) {

                              // TODO Auto-generated catch block

                              e.printStackTrace();

                  }

              }


To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply