Re: TomEE embedded ActiveMQ + Injected JMSContext -> Abandoned Connections

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: TomEE embedded ActiveMQ + Injected JMSContext -> Abandoned Connections

jgallimore
Thanks for this. I have reproduced your issue. I've opened a JIRA on the
TomEE side: https://issues.apache.org/jira/browse/TOMEE-2506, and added the
tests to reproduce:
https://github.com/apache/tomee/commit/e58ff848a3a80938d4d99fc9bcfeaade5a72d644

I think this is a TomEE issue rather than an ActiveMQ issue. I added the
code to AutoConnectionTracker in TomEE to warn when transaction resources
weren't properly closed, and that appears to be showing the issue
in org.apache.openejb.resource.activemq.jms2.JMSContextImpl. I'll dig in
and take a look.

Jon

On Wed, Apr 3, 2019 at 11:19 PM Ted Spradley <[hidden email]> wrote:

> Jon,
>
> EJB - here is a sample below.
>
> Thank you for looking at this.
> Ted S.
>
> @Named
> @LocalBean
> @TransactionManagement(TransactionManagementType.CONTAINER)
> @Stateless
> public class QueueSenderSessionBean
> {
>
>     @Resource(mappedName = "jms/localNotificationQueue")
>     private Queue localQueue;
>
>     @Inject
>     @JMSConnectionFactory("jmsConnectionFactory")
>     private JMSContext jmsContext;
>
>
>     public void sendMessage(String message)
>     {
>         try
>         {
>             TextMessage textMessage =
>                        jmsContext.createTextMessage(message);
>             textMessage.setStringProperty("someProperty", "someValue" );
>
>             jmsContext.createProducer().
>                         setDeliveryMode(DeliveryMode.PERSISTENT).
>                         send(localQueue,
>                             textMessage);
>         }
>         catch (JMSException e)
>         {
>             e.printStackTrace();
>         }
>     }
> }
>
>
> ´╗┐On 4/3/19, 4:35 PM, "Jonathan Gallimore" <[hidden email]>
> wrote:
>
>     Sounds like an issue we need to look at on the TomEE side (adding
>     [hidden email])
>
>     What are you injecting into - an EJB or CDI bean?
>
>     Your code shows a consumer - how are you sending your messages?
>
>     Jon
>
>     On Wed, 3 Apr 2019, 19:43 tkspradley, <[hidden email]> wrote:
>
>     > First posting here. Please let me know if I need to include other
>     > environment
>     > information
>     >
>     > Environment: (TomEE)/9.0.12 - CentOS 7 - java-1.8.0-openjdk-1.8.0
>     >
>     > Issue: Abandoned connection warning issued after every send and
> receive
>     >
>     > Question: The container eventually releases the abandoned
> connections and
>     > delivers some of the messages. Is this expected behavior? Am I
> supposed to
>     > release the Connection somehow? If I use a try with resources block
> to
>     > create a context using connection factory, resources are release
> when out
>     > of
>     > scope, but messages aren't visible to the messages consumer selector
> even
>     > though the messages do appear using QueueBrowser.
>     >
>     > Thank you,
>     > Ted S.
>     >
>     > Execution:
>     >
>     > If I send 20 messages sequentially, an exception is thrown on
> message 11:
>     > javax.jms.JMSRuntimeException: No ManagedConnections available within
>     > configured blocking timeout ( 5000 [ms] )
>     >
>     > Configuration:
>     >         <Resource id="jmsConnectionFactory"
>     > type="javax.jms.ConnectionFactory">
>     >             connectionMaxIdleTime = 15 Minutes
>     >             connectionMaxWaitTime = 5 seconds
>     >             poolMaxSize = 10
>     >             poolMinSize = 0
>     >             resourceAdapter = Default JMS Resource Adapter
>     >             transactionSupport = xa
>     >         </Resource>
>     >
>     >     @Inject
>     >     @JMSConnectionFactory("jmsConnectionFactory")
>     >     private JMSContext jmsContext;
>     >     @Resource(mappedName = "jms/localNotificationQueue")
>     >     private Queue localQueue;
>     >
>     >       JMSConsumer jmsConsumer =
>     >                 jmsContext.createConsumer(localQueue,
>     > "someProperty='someValue'");
>     >
>     >        Message localMessage =
>     >                     jmsConsumer.receiveNoWait();
>     >
>     > log=>
>     > Apr 03, 2019 1:10:21 PM
> org.apache.openejb.resource.AutoConnectionTracker$1
>     > beforeCompletion
>     > WARNING: Transaction complete, but connection still has handles
> associated:
>     > ManagedConnectionInfo:
>     >
>     >
>     >
>     >
>     > --
>     > Sent from:
>     > http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>     >
>
>
>
>