You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Dignesh <dg...@opentext.com.INVALID> on 2020/07/06 08:46:45 UTC

Consumer instances are not created as per MDB instance limt

I am using TomEE 7.0.2 and 8.0.0 . I notice the consumer instances are not
created as specified in tomee.xml file.
Below is my configuration in tomee.xml file.

<Container id="TEST MDB Container" ctype="MESSAGE">
			ResourceAdapter = JmsResourceAdapter
			InstanceLimit = 10
</Container>

I have also set maxsessions property on an MDB to 50.

However, when I monitor the MDB's via jconsole tool, I notice that only one
consumer is shown in tool. -Since I am setting the InstaceLimit to 10 , I
would expect 10 instances of the consumer to be shown in the tool . 

Does it mean , TomEE is not creating the no of consumer instances as
specified in the configuration file ? Or is their additional configuration
that needs to be done, which I am missing ?





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: Consumer instances are not created as per MDB instance limt

Posted by Jonathan Gallimore <jo...@gmail.com>.
That sounds correct to me. The issue setting the InstanceLimit was likely
introduced in a change where we added the option for TomEE to operate a
pool for the MDB container. Previously TomEE did not have that feature as
many resource adapters have endpoint pooling in them. We eventually ran
into one that didn't - if I remember correctly this in turn caused MDBs to
be initialized and discarded which led to performance issues,
particularly if you have some complex logic in a @PostConstruct method.

I can't remember exactly when this was introduced -  but according to git,
it was around TomEE 7.0.5.

Jon

On Tue, Jul 7, 2020 at 1:16 PM Dignesh <dg...@opentext.com.invalid> wrote:

> Thank you very much Jon. It is clear now.
> One more question. Looking at the code changes you made for 7.0.9 version,
> I think the instance Limit was honored properly in 7.0.2 -- at least by
> looking into the 7.0.2 code base. The only piece of block missing was JMS
> monitoring. Can you please confirm if this is correct. May be the
> instanceLimit not setting properly was introduced in later versions of
> tomee..?
>
> MdbContainer.java
> <http://tomee-openejb.979440.n4.nabble.com/file/t375864/MdbContainer.java>
>
>
> I have attached the 7.0.2 version of file by adding the diff(s) change.Hope
> the diff changes i copied are fine :)
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>

Re: Consumer instances are not created as per MDB instance limt

Posted by Dignesh <dg...@opentext.com.INVALID>.
Thank you very much Jon. It is clear now.
One more question. Looking at the code changes you made for 7.0.9 version, 
I think the instance Limit was honored properly in 7.0.2 -- at least by
looking into the 7.0.2 code base. The only piece of block missing was JMS
monitoring. Can you please confirm if this is correct. May be the
instanceLimit not setting properly was introduced in later versions of
tomee..?

MdbContainer.java
<http://tomee-openejb.979440.n4.nabble.com/file/t375864/MdbContainer.java>  

I have attached the 7.0.2 version of file by adding the diff(s) change.Hope
the diff changes i copied are fine :) 



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: Consumer instances are not created as per MDB instance limt

Posted by Jonathan Gallimore <jo...@gmail.com>.
Sorry, my last reply was a little rushed as I was on my phone. With respect
to JBoss, I don't know how those stats are computed, so I can't make too
much comment there. In TomEE, the stuff under org.apache.activemq is
provided by the ActiveMQ embedded inside TomEE. TomEE provides these
"as-is", so we don't have any control over the values. Your config exposes
the broker with an NIO OpenWire port, so any stats would also include
external connections to that port.

I did a quick test with your config, and used the ActiveMQ
producer/consumer commands (e.g. ./activemq consumer --brokerUrl
nio://localhost:54545 --destination queue://TEST --messageCount 100000)
which use 20 threads by default, and this also shows as one consumer in the
broker JMX stats.

For reference, here's the class that provides the MBean you're looking at
in JConsole:
https://github.com/apache/activemq/blob/activemq-5.15.x/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/SubscriptionView.java
-
you're really looking at subscription to the queue for the connection, so
I'd only expect to see one.

Usually when I see these types of questions, people are really more
concerned about concurrency and getting the right throughput through their
MDBs, and having an accurate measure of that. The "instanceCount" should
provide an accurate measure there (feedback is welcome!), but a test is
worthwhile. This is a basic test that you can build on:
https://github.com/apache/tomee/blob/master/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MaxInstanceEndpointHandlerTest.java

It:

* loads a queue up with messages:
https://github.com/apache/tomee/blob/master/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MaxInstanceEndpointHandlerTest.java#L90-L96
* starts the MDB:
https://github.com/apache/tomee/blob/master/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MaxInstanceEndpointHandlerTest.java#L99
* and checks we had the concurrency we expected (30 concurrent instances):
https://github.com/apache/tomee/blob/master/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MaxInstanceEndpointHandlerTest.java#L102

If you wanted to have a go building on this test to include multiple queues
and MDBs that would be really awesome. Adding some checks in there for the
instance count through JMX would be a good improvement too.

I hope that helps. I appreciate that this isn't necessarily
straightforward, so if you have more questions, please ask!

Jon


On Tue, Jul 7, 2020 at 9:38 AM Dignesh <dg...@opentext.com.invalid> wrote:

> Thank you Jon.
> I was expecting the consumer count shown in the jconsole tool to be matched
> with maxsessions/InstanceLimit.
>
> When I switch the Appserver to JBoss, I do notice the consumer count value
> shown properly.
>
> If it is expected in TomEE, the only way to find the number of consumers is
> via InstanceLimit ? Am i correct ? Jboss-ConsumerCoun.png
> <
> http://tomee-openejb.979440.n4.nabble.com/file/t375864/Jboss-ConsumerCoun.png>
>
> TomEE_-_consumercount.JPG
> <
> http://tomee-openejb.979440.n4.nabble.com/file/t375864/TomEE_-_consumercount.JPG>
>
>
> I have attached the screenshots of both the application servers.
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>

Re: Consumer instances are not created as per MDB instance limt

Posted by Dignesh <dg...@opentext.com.INVALID>.
Thank you Jon.
I was expecting the consumer count shown in the jconsole tool to be matched
with maxsessions/InstanceLimit.

When I switch the Appserver to JBoss, I do notice the consumer count value
shown properly.

If it is expected in TomEE, the only way to find the number of consumers is
via InstanceLimit ? Am i correct ? Jboss-ConsumerCoun.png
<http://tomee-openejb.979440.n4.nabble.com/file/t375864/Jboss-ConsumerCoun.png>  
TomEE_-_consumercount.JPG
<http://tomee-openejb.979440.n4.nabble.com/file/t375864/TomEE_-_consumercount.JPG>  

I have attached the screenshots of both the application servers.



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: Consumer instances are not created as per MDB instance limt

Posted by Jonathan Gallimore <jo...@gmail.com>.
That's expected. ActiveMQ multiplexes multiple sessions into one
connection, so you'll only see one consumer there. The number of
concurrently active inactive MDB instances is not a 1:1 with the consumer
count.

Jon

On Tue, 7 Jul 2020, 07:30 Dignesh, <dg...@opentext.com.invalid> wrote:

> Hi Jon,
>
> Looks like you resolved the issue -
> https://issues.apache.org/jira/browse/TOMEE-2859
> I have made the diff(s) of changes locally, I am now able to see the
> instances count in JMX.
>
> screenshot.JPG
> <http://tomee-openejb.979440.n4.nabble.com/file/t375864/screenshot.JPG>
> instancecount.JPG
> <http://tomee-openejb.979440.n4.nabble.com/file/t375864/instancecount.JPG>
>
>
> If you refer the instanceCount screenshot, the values are populated
> properly.
> However, I was under impression that all the instances of consumers will be
> shown in JMX broker. But I still see only one consumer  - refer to
> screenshot.jpg.
>
> Is that expected ? - TomEE will only show the instancecount and
> instanceLimit, but consumer displayed will always be one ?
>
> Thank you once again.
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>

Re: Consumer instances are not created as per MDB instance limt

Posted by Dignesh <dg...@opentext.com.INVALID>.
Hi Jon,

Looks like you resolved the issue -
https://issues.apache.org/jira/browse/TOMEE-2859 
I have made the diff(s) of changes locally, I am now able to see the
instances count in JMX.

screenshot.JPG
<http://tomee-openejb.979440.n4.nabble.com/file/t375864/screenshot.JPG>  
instancecount.JPG
<http://tomee-openejb.979440.n4.nabble.com/file/t375864/instancecount.JPG>  

If you refer the instanceCount screenshot, the values are populated
properly. 
However, I was under impression that all the instances of consumers will be
shown in JMX broker. But I still see only one consumer  - refer to
screenshot.jpg.

Is that expected ? - TomEE will only show the instancecount and
instanceLimit, but consumer displayed will always be one ?

Thank you once again.



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: Consumer instances are not created as per MDB instance limt

Posted by Dignesh <dg...@opentext.com.INVALID>.
Thank you very much once again Jon.

If you can help me in point at the diff(s), I will try to update my
environment locally.

It would be really helpful, if you can expose instance limit via JMX. this
helps us to monitor the beans during performance tuning.




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: Consumer instances are not created as per MDB instance limt

Posted by Jonathan Gallimore <jo...@gmail.com>.
> It would be really helpful to us if you can provide the fix on 7.0.2 and
8.0.0 .

I'll provide it for 7.0.x (7.0.9), 7.1.x (7.1.4), and 8.0.x (8.0.4). I'm
expecting to kick off releases for those this week. 7.0.2 and 8.0.0 are
both released, so I can't update them. I'll happily point you at the
diff(s) however.

> Also  just wanted to confirm with your fix, I would be able to see as
many instances as configured in Jconsole tool ?

It looks like we don't expose the instance count/limit via JMX. I was
looking to add that as well.

Jon



On Mon, Jul 6, 2020 at 3:08 PM Dignesh <dg...@opentext.com.invalid> wrote:

> Also  just wanted to confirm with your fix, I would be able to see as many
> instances as configured in Jconsole tool ?
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>

Re: Consumer instances are not created as per MDB instance limt

Posted by Dignesh <dg...@opentext.com.INVALID>.
Also  just wanted to confirm with your fix, I would be able to see as many
instances as configured in Jconsole tool ?




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: Consumer instances are not created as per MDB instance limt

Posted by Dignesh <dg...@opentext.com.INVALID>.
Thank you very much Jon.

It would be really helpful to us if you can provide the fix on 7.0.2 and
8.0.0 . By any chance is it possible ? So any specific jars or class within
the jars present in lib to be updated. - I am okay to do so. 




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: Consumer instances are not created as per MDB instance limt

Posted by Jonathan Gallimore <jo...@gmail.com>.
I managed to reproduce this here. I used a very simple MDB that just echoed
a message to the console and slept for 5 seconds.

I'd expect to see a single consumer at that point in JConsole, but I'd
expect to see <InstanceLimit> or <MaxSession>  number of MDB instances all
running concurrently. As it happens, with your config, I was seeing 10.

I tweaked your config a little:

  <Container id="mdbid" type="MESSAGE">
      ResourceAdapter = JmsResourceAdapter
      InstanceLimit = 100
      activation.maxSessions = 80
  </Container>
    <Resource id="JmsResourceAdapter" type="ActiveMQResourceAdapter">
      BrokerXmlConfig = xbean:file:${catalina.home}/conf/activemq.xml
      ServerUrl =
nio://localhost:54545?soTimeout=60000&amp;daemon=true&amp;keepAlive=true&amp;connectionTimeout=120000&amp;wireFormat.tcpNoDelayEnabled=true&amp;wireFormat.maxInactivityDuration=240000&amp;wireFormat.maxInactivityDurationInitalDelay=120000
      threadPoolSize = 100
  </Resource>
  <Resource id="jms/ConnectionFactory" type="javax.jms.ConnectionFactory">
      ResourceAdapter = JmsResourceAdapter
      connectionMaxWaitTime = 30 seconds
      MaxThreadPoolSize = 80
  </Resource>

It does appear that you've run into a bug where InstanceLimit isn't picked
up correctly, however. I should have a fix committed for that by the end of
the day.

Jon

On Mon, Jul 6, 2020 at 1:49 PM Dignesh <dg...@opentext.com.invalid> wrote:

> tomee.xml <
> http://tomee-openejb.979440.n4.nabble.com/file/t375864/tomee.xml>
> a.ear <http://tomee-openejb.979440.n4.nabble.com/file/t375864/a.ear>
> I have attached the sample ear file and the tomee.xml file.
> I would be helpful for you to replicate the issue internally.
> Also I have attached the screenshot of single consumer shown in the
> Jconsole
> tool.
> Capture.JPG
> <http://tomee-openejb.979440.n4.nabble.com/file/t375864/Capture.JPG>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>

Re: Consumer instances are not created as per MDB instance limt

Posted by Dignesh <dg...@opentext.com.INVALID>.
tomee.xml <http://tomee-openejb.979440.n4.nabble.com/file/t375864/tomee.xml>  
a.ear <http://tomee-openejb.979440.n4.nabble.com/file/t375864/a.ear>  
I have attached the sample ear file and the tomee.xml file. 
I would be helpful for you to replicate the issue internally.
Also I have attached the screenshot of single consumer shown in the Jconsole
tool. 
Capture.JPG
<http://tomee-openejb.979440.n4.nabble.com/file/t375864/Capture.JPG>  



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: Consumer instances are not created as per MDB instance limt

Posted by Jonathan Gallimore <jo...@gmail.com>.
Thanks. It looks ok, but I'll plug it into an instance here and run some
tests.

Jon

On Mon, Jul 6, 2020 at 10:25 AM Dignesh <dg...@opentext.com.invalid> wrote:

> Yes I am using ActiveMQ as my broker.
>
> I am attaching the following configuration files. active-config.xml
> <http://tomee-openejb.979440.n4.nabble.com/file/t375864/active-config.xml>
>
> tomee_-_Copy.xml
> <http://tomee-openejb.979440.n4.nabble.com/file/t375864/tomee_-_Copy.xml>
>
> 1.tomee.xml
> 2.activemq.xml
>
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>

Re: Consumer instances are not created as per MDB instance limt

Posted by Dignesh <dg...@opentext.com.INVALID>.
Yes I am using ActiveMQ as my broker.

I am attaching the following configuration files. active-config.xml
<http://tomee-openejb.979440.n4.nabble.com/file/t375864/active-config.xml>  
tomee_-_Copy.xml
<http://tomee-openejb.979440.n4.nabble.com/file/t375864/tomee_-_Copy.xml>  
1.tomee.xml
2.activemq.xml





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Re: Consumer instances are not created as per MDB instance limt

Posted by Jonathan Gallimore <jo...@gmail.com>.
Just to confirm - are you using ActiveMQ as your broker? If you have any
additional config around that, which you can share, that would be great.

Thanks

Jon

On Mon, Jul 6, 2020 at 9:46 AM Dignesh <dg...@opentext.com.invalid> wrote:

> I am using TomEE 7.0.2 and 8.0.0 . I notice the consumer instances are not
> created as specified in tomee.xml file.
> Below is my configuration in tomee.xml file.
>
> <Container id="TEST MDB Container" ctype="MESSAGE">
>                         ResourceAdapter = JmsResourceAdapter
>                         InstanceLimit = 10
> </Container>
>
> I have also set maxsessions property on an MDB to 50.
>
> However, when I monitor the MDB's via jconsole tool, I notice that only one
> consumer is shown in tool. -Since I am setting the InstaceLimit to 10 , I
> would expect 10 instances of the consumer to be shown in the tool .
>
> Does it mean , TomEE is not creating the no of consumer instances as
> specified in the configuration file ? Or is their additional configuration
> that needs to be done, which I am missing ?
>
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html
>