Your first and third URIs should work, so maybe this is something specific
to DefaultJmsListenerContainerFactory()? I don't have experience using it,
but an answer on
https://stackoverflow.com/questions/33339224/spring-jms-listener-container-concurrency-attribute-not-working
lists 3 ways to set prefetch under Spring Boot, including via
application.properties which looks like what you're doing. Are either of
the other two possible without the vendor change you're waiting for?

Does it work if you try tcp to the active broker (no failover), just to
test?

Tim

On Thu, Feb 24, 2022, 11:03 AM Bindu Wavell <bwav...@google.com.invalid>
wrote:

> Hi folks,
>
> We are using ActiveMQ Classic (5.16.1). I have 3 consumer processes and 2
> ActiveMQ brokers setup with the shared storage active/passive mode.
>
> I setup the connection URI like this:
>
>
> failover:(tcp://broker1:61616,tcp://broker2:61616)?timeout=3000&nested.jms.prefetchPolicy.queuePrefetch=1
>
> Also tried this:
>
>
> failover:(tcp://broker1:61616,tcp://broker2:61616)?timeout=3000&jms.prefetchPolicy.queuePrefetch=1
>
> And this:
>
>
> failover:(tcp://broker1:61616?jms.prefetchPolicy.queuePrefetch=1,tcp://broker2:61616?jms.prefetchPolicy.queuePrefetch=1)?timeout=3000
>
> Looking through the web console at active consumers for a queue I care
> about I see:
>
> Prefetch
> Max Pending
> 1000
> 0
>
> For each of the consumers. I'm also seeing Enqueues > 10. We have an
> application where there are not a ton of messages, but the consumers take a
> while to process messages. In the current environment, when we start our
> clients, we see most messages going to one client. Over time this does seem
> to even out, but I think it's indicative of prefetch not being applied.
>
> Am I doing this right?
>
> FWIW, the client is a Spring Boot application built by a vendor and I'm
> trying to get the vendor to actually allow us to configure prefetch and
> they will set it from code. That is taking a long time, so I was excited it
> would be possible to set this via the connection URI.
>
> The vendor sets up the jmsListenerConnectionFactory in
> their JmsListenerConfigurer implementation like this:
>
>
> @Bean
> public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(
> final ConnectionFactory connectionFactory,
> final TransformMessageConverter transformMessageConverter)
> {
> final DefaultJmsListenerContainerFactory factory = new
> DefaultJmsListenerContainerFactory();
> factory.setConnectionFactory(connectionFactory);
> factory.setMessageConverter(transformMessageConverter);
> factory.setErrorHandler(t -> logger.error("JMS error: " + t.getMessage(),
> t));
> factory.setTransactionManager(transactionManager(connectionFactory));
> return factory;
>
>
> }
>

Reply via email to