[ 
https://issues.apache.org/jira/browse/ARTEMIS-2375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17019788#comment-17019788
 ] 

Christopher L. Shannon commented on ARTEMIS-2375:
-------------------------------------------------

I thought about trying to use the existing binding and address model (maybe 
piggy backing off diverts) but I don't see how it could work the way I want or 
need it to, but maybe I am missing something.  

Right now a single queue is tied to a consumer, which means for a consumer on a 
wildcard address to be able to receive messages from multiple matching address 
the only way is to eventually route those messages to the wildcard address, 
either exclusive or non exclusive (duplicates) so the queue that is attached to 
that consumer and bound to the wildcard address gets the messages. The big 
problem with non-exclusive (current behavior) is duplicates and orphaned 
messages.  The problem with the exclusive case is that messages get sent to the 
wildcard but then a non-wildcard consumer can't get them.  I need to have the 
wildcard consumer OR another consumer on a non-wildcard matching address be 
able to consume.  Ie a consumer on queue.test.# and another consumer on 
queue.test.1 should round robin messages off queue.test.1  

So again, maybe I'm missing something but I just don't see how to accomplish 
what I need without having the messages be routed only to the original 
addresses they were sent to and then having the wildcard consumer simply 
subscribe to those matching addresses.   I have a patch working for this in a 
custom build and it seems to work well so far.  I haven't written tests for it 
yet (or added a config option to enable/disable) but I could push up the commit 
I have if you want to take an early look.

> JMS, Wildcard destination consumer, and Acknowledgements going to wrong queue
> -----------------------------------------------------------------------------
>
>                 Key: ARTEMIS-2375
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2375
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.9.0
>            Reporter: Craig Schmidt
>            Assignee: Justin Bertram
>            Priority: Major
>
> I have an ActiveMQ server set up where I have multiple (and unbounded) queues 
> which differ only in the last component. e.g. myqueue.1, myqueue.2, 
> myqueue.4, etc. The last component is from a database that will have a 
> varying set of customers defined - and I want to set up one queue for each 
> customer. (I want a separate queue - the third party we're talking to needs 
> throttling at our 'customer' level. 
> The address setting looks like this in broker.xml: 
> {code:xml}
> <address-setting match="myqueue.#">
>   <dead-letter-address>myqueue.DLQ</dead-letter-address>
>   <expiry-address>myqueue.ExpiryQueue</expiry-address>
>   <redelivery-delay>500</redelivery-delay>
>   <max-size-bytes>-1</max-size-bytes>
>   <message-counter-history-day-limit>10</message-counter-history-day-limit>
>   <address-full-policy>PAGE</address-full-policy>
>   <auto-create-queues>true</auto-create-queues>
>   <auto-create-addresses>true</auto-create-addresses>
>   <auto-create-jms-queues>true</auto-create-jms-queues>
>   <auto-create-jms-topics>true</auto-create-jms-topics>
>   <max-delivery-attempts>3</max-delivery-attempts>
> </address-setting>
> {code}
>  I have a producer that creates the queue name based on the customer key, and 
> uses JmsMessagingTemplate.convertAndSent(queueName, message). I have a 
> consumer annotated like this: 
> {code:java}
> @JmsListener(destination = "myqueue.#", containerFactory = 
> "throttledLongCodeFactory")
> public void processLongCodeMessage1(Session session, Message<MessageRequest> 
> message) throws JMSException { 
>   //... do the message handling - no ActiveMQ accesses in here... 
>   session.commit();
> }
> {code}
> FWIW, here's the code for the throttledLongCodeFactory: 
> {code:java}
> @Bean public DefaultJmsListenerContainerFactory 
> throttledLongCodeFactory(DefaultJmsListenerContainerFactoryConfigurer 
> configurer) {
>   ActiveMQConnectionFactory connectionFactory = 
> createActiveMQConnectionFactory();
>   // For throttling. Used to limit the number of messages a consumer will 
> handle per second. Default is -1. 
>   Integer maxConsumerRate = 
> appProperties.getArtemis().getLongCode().getMaxConsumerRate(); 
>   if (maxConsumerRate != null) {
>     connectionFactory.setConsumerMaxRate(maxConsumerRate); 
>   } 
>   // This provides all boot's default to this factory, including the message 
> converter 
>   DefaultJmsListenerContainerFactory factory = new 
> DefaultJmsListenerContainerFactory(); 
>   configurer.configure(factory, connectionFactory);
>   return factory;
> }
> {code}
>  What I'm finding in looking at the ActiveMQ Management Console is that the 
> consumer ACK's are going to a (new) queue "myqueue.#" (i.e. literally has the 
> '#' in the name), rather than the actual source queue for each message. In 
> the consumer, I can see the actual source queue name (e.g. "myqueue.2") by 
> inspecting the ClientMessageImpl field 'address'. What I'd like is for the 
> ACK's to go to the source queue. the way it is, my specific queues are just 
> building up the number of messages they contain, which isn't doing the 
> Artemis server memory any good.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to