You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Jonathan Gallimore (Jira)" <ji...@apache.org> on 2020/03/31 15:04:00 UTC

[jira] [Commented] (TOMEE-2781) ActiveMQ producer not closed or destroyed

    [ https://issues.apache.org/jira/browse/TOMEE-2781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17071865#comment-17071865 ] 

Jonathan Gallimore commented on TOMEE-2781:
-------------------------------------------

With respect to this: "Then perform several GET calls with a browser and you will see the number of Producer increasing (1 per call)."

How are you measuring that?

I'm running the simple-jms example connected up to an external JMS broker, and checking the producer count in the ActiveMQ console. Looks ok so far. Are you measuring this another way?

> ActiveMQ producer not closed or destroyed
> -----------------------------------------
>
>                 Key: TOMEE-2781
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2781
>             Project: TomEE
>          Issue Type: Bug
>          Components: TomEE Core Server
>    Affects Versions: 8.0.0-Final, 8.0.1
>            Reporter: François Courtault
>            Priority: Blocker
>
> Hello,
> This issue is linked to TOMEE-2770[.|https://issues.apache.org/jira/projects/TOMEE/issues/TOMEE-2770?filter=allopenissues]
> 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;
>  
> {color:#808000}@Resource
> {color}{color:#000080}private {color}ConnectionFactory {color:#660e7a}connectionFactory{color};
>  
> @GET
> @Path("downloadInfo")
>  public Response postDownloadInfoJMS() {
> {color:#172b4d}    try (final Connection connection = connectionFactory.createConnection()) {
>         final Session session = connection.createSession();
>         final MessageProducer messageProducer = session.createProducer(messageQueue);
>         messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);{color}
> {color:#172b4d}
>         final Message message = session.createTextMessage("Test");
>        messageProducer.send(message);
>        System.out.println("Message sent !");
>     } catch (JMSException e) {
>        e.printStackTrace();
>     }{color}
>  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:
>     {color:#172b4d}Connection connection ={color} null;
>     try {
> {color:#172b4d}       try {{color}
> {color:#172b4d}           connection = connectionFactory.createConnection();
>            final Session session = connection.createSession();
>            final MessageProducer messageProducer = session.createProducer(messageQueue);
>            messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);{color}
> {color:#172b4d}
>            final Message message = session.createTextMessage("Test");
>            messageProducer.send(message);
>           System.out.println("Message sent !");
>        } finally {{color}
> {color:#172b4d}         connection.close();{color}
> {color:#172b4d}       }{color}
> {color:#172b4d}    } {color}{color:#172b4d}catch (JMSException e) {
>        e.printStackTrace();
>     }{color}
>  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.
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)