You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "François Courtault (Jira)" <ji...@apache.org> on 2020/04/01 11:22: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=17072663#comment-17072663 ]
François Courtault commented on TOMEE-2781:
-------------------------------------------
Hello Jonathan,
Forget to add the following line in the sample I have provided to you:
{color:#808000}@TransactionAttribute{color}(TransactionAttributeType.{color:#660e7a}NEVER{color})
Using JConsole, you will see that the number of dynamicProducer increases at each GET call.
> 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)