Reputation: 981
I have an MDB in Jboss 7 application that acts as a consumer of a queue in ActiveMQ. This is how the connection is made from JBoss
/subsystem=resource-adapters/resource-adapter=activemq-rar-5.6.0.rar/config-properties="ServerUrl":add(value="tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=1")
On the MDB these are the annotations:
@MessageDriven(name = "MyConsumerMessageBean", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "myQueue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "maxSessions", propertyValue="2")})
@ResourceAdapter(value = "activemq-rar-5.6.0.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
When JBoss connects to Active MQ I see that the value of jms.prefetchPolicy.queuePrefetch=1 is passed to the activeMQ server in the connection attempt as shown in the JBoss server log.
2014-08-28 21:33:04,183 INFO [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-short-running-threads-threads - 3) Successfully established connection to broker [tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=1]
However, when I look at the ActiveMQ queue screen and drill down to this consumer, I see that the value of PreFetch Max Pending column is 20. Where is this number 20 coming from and why is the value of 1 not being honored by ActiveMQ.
I have also tried to set other value "jms.prefetchPolicy.all=1" via the same mechanism and that didn't work either. I am on JBoss AS 7.1.1 Final and ActiveMQ 5.6.0
Thanks
Upvotes: 0
Views: 4403
Reputation: 11
In JBoss EAP the org.apache.activemq.ra.ActiveMQManagedConnectionFactory is configured that doesn't take parameters from the broker url as usually. To configure prefetch you can add the following config-properties to the resource-adapter:
<config-property name="QueuePrefetch">20</config-property>
<config-property name="TopicPrefetch">20</config-property>
<config-property name="DurableTopicPrefetch">20</config-property>
<config-property name="OptimizeDurableTopicPrefetch">20</config-property>
<config-property name="QueueBrowserPrefetch">20</config-property>
<config-property name="InputStreamPrefetch">20</config-property>
Upvotes: 1
Reputation: 933
First make sure you are not setting at the consumer level ( YOUR.QUEUE?consumer.prefetchSize=20 for example)
That is the only other place that should override what where you have it set in your connection factory.
Otherwise I would also look at using a newer version of AMQ. There was a bug if I recall correctly that caused the broker to not honor prefetch values.
In your activemq.xml look to see if you have a destination policy with a prefetch of 20 if you did not find it on the consumer level. Setting it at the destination policy level overrides the broker default (1000), but the URI argument should override that setting. This could be an validation that you are running into the issue I mentioned.
Upvotes: 1