Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-2781

ActiveMQ producer not closed or destroyed

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Blocker
    • Resolution: Unresolved
    • Affects Version/s: 8.0.0-Final, 8.0.1
    • Fix Version/s: None
    • Component/s: TomEE Core Server
    • Labels:
      None

      Description

      Hello,

      This issue is linked to TOMEE-2770.

      We have the same kind of issue.

      Sample to repoduce the issue:

      @Stateless

      @Path("v1/notifications")

      public class NotificationResource {

      public static final String QUEUE_NAME = "jms/myQueue";

       

      @Resource(name = QUEUE_NAME)

      private Queue messageQueue;

       

      @Resourceprivate ConnectionFactory connectionFactory;

       

      @GET

      @Path("downloadInfo")

       public Response postDownloadInfoJMS() {

          try (final Connection connection = connectionFactory.createConnection()) {
              final Session session = connection.createSession();
              final MessageProducer messageProducer = session.createProducer(messageQueue);
              messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);


              final Message message = session.createTextMessage("Test");

             messageProducer.send(message);
             System.out.println("Message sent !");
          } catch (JMSException e) {        e.printStackTrace();     }

       return Response.accepted().build();

       }

      }

       

      And a beans.xml with bean-discovery-mode="all".

       

      Then perform several GET calls with a browser and you will see the number of Producer increasing (1 per call).

       

      We have the same issue if we change the postDownloadInfoJMS method implementation by:

          Connection connection = null;

          try {

             try {

                 connection = connectionFactory.createConnection();
                 final Session session = connection.createSession();
                 final MessageProducer messageProducer = session.createProducer(messageQueue);
                 messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);


                 final Message message = session.createTextMessage("Test");

                 messageProducer.send(message);
                System.out.println("Message sent !");
             } finally {

               connection.close();

             }

          } catch (JMSException e) {        e.printStackTrace();     }

       return Response.accepted().build();

       }

      }

       

      The only way to fix that is, in the finally bock to close everything

      messageProducer.close();
      session.close();

      connection.close();

       

      But it's not acceptable because the try with resource should work and closing a connection, as per spec, should close message producers and sessions. 

       

       Best Regards.

       

       

       

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fcourtau François Courtault
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: