0 Replies Latest reply on May 29, 2003 2:54 AM by jboss_user_1

    JMS and EJB in transaction

    jboss_user_1 Newbie

      I have tried to involve a Topic in an ejb method that is under transaction.Even though I throw the Runtime Exception the message published is recieved by listener.It is not rolling back the messages.

      The code is following

      * @ejb.interface-method
      * view-type="remote"
      * @ejb:transaction type="Required"

      public String helloworld(String name) throws RemoteException{
      String hello=null;
      hello= "Hello from "+name+"Today is :"+new java.util.Date();
      InitialContext lContext = new InitialContext();
      TopicConnection conn=null;
      TopicConnectionFactory qfactory=(TopicConnectionFactory)lContext.lookup("ConnectionFactory");
      TopicSession session=conn.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
      Topic q=(Topic)lContext.lookup("topic/testTopic");
      TopicPublisher sender =session.createPublisher(q);
      TextMessage message=session.createTextMessage();
      for(int i=0;i<4;i++){
      message.setText("Dummy Message Created::"+i+new java.util.Date());
      System.out.println("Message Published"+new java.util.Date());
      int i=0;
      System.out.println("Rolling Back");
      throw new Exception("RollBack Transaction");

      }catch(Exception e){

      throw new EJBException( "Remote exception occured while removing generator session bean: " + e.getMessage() );

      return hello;


      Any pointers