Multiple instances of the same Springboot application but only 1 instance consumes messages from ActiveMQ queue - spring-boot

I am running multiple instances of the same Spring Boot 2.0.4 Application, for scaling purposes, that consume messages from an ActiveMQ queue using the following:
#JmsListener(destination = "myQ")
Only the first consumer receives messages and if I stop the first consumer the second instance starts receiving the messages. I want each consumer to consume a message, not the same message, in a round robin fashion. But only the first consumer consumes messages.

It sounds like you want a JMS Topic rather than a Queue. You should also research durable subscriptions, shared subscriptions, and durable topics before you settle on the configuration you need for your setup.
See:
JMS API Programming Model (Search for JMS Message Consumers)
Queues vs Topics
Durable Queues and Topics

Related

Spring DSL Solace Integration: How to set max message per poll

I am using spring, dsl, solace integration with spring boot. My application with one subscriber is able to poll approx 80 messages per second and 4 subscribers able to poll approx 125 messages per seconds. I want to process at least 500 messages per second. My JMS flow is stated below-
public #Bean IntegrationFlow defaultJmsFlow()
{
return IntegrationFlows.from(
//read JMS topic
Jms.messageDrivenChannelAdapter(this.connectionFactory).destination(this.config.getInputQueueName()).errorChannel(errorChannel()).configureListenerContainer(c ->
{
final DefaultMessageListenerContainer container = c.get();
container.setSessionTransacted(true);
container.setMaxConcurrentConsumers(10);
container.setConcurrentConsumers(4);
}).get())
.channel(messageProcessingChannel()).get();
}
After reading messages I'm sending those to DirectChannel. Any special configuration need to make to increase performance of my application so that at least 500 messages per seconds gets processed.
It is strongly recommended to cache consumers when integrating Spring JMS with Solace. This way, the connection stays persistent and messages will be delivered to the consumer quickly without the overhead of unbinding, disconnecting, and reconnecting. This can be set in the DefaultMessageListenerContainer with container.setCacheLevel(3).
If you are using concurrent consumers to read messages from the same Solace queue, ensure that the Solace queue is non-exclusive. Exclusive queues will deliver messages to one active consumer and non-exclusive queues will deliver messages round robin to all consumers.

Persistence Message Queue behavior with no subscribers (ActiveMQ)

We develop NMS product that has been deployed by couple of telecom operators. Our application (uses ActiveMQ) will publish Fault notifications to the Fault Queue, the messages are set to be persistent. These messages are consumed by third party JMS clients. Not all the customers will have a notification client to consume the events(some of the deployments will not have any subscriptions). The question is, does ActiveMQ persist the messages if the queue never had a subscriber connected to the Queue?.
The Broker will persist messages to a Queue regardless of the presence of consumers when the message is tagged as persistent. That is the general contract of the Queue model.

Who consumes the queue on hornetQ

I have many applications (about 60) whom consumes messages on hornetQ queues.
Normally, each application consumes its own queue but I have some messages on a specific queue whom are consume by an unkown application.
For exemple, normally the application A consume the queueA but for a weird reason, some messages are not consume by this application (I log every entry in Jms listener) and I don't know who consumes those messages.
Is it possible to check on hornetQ what application consumes a message ?
You can use Interceptors to monitor at the server side which clients connect to the topic in question. Basically, you just write a class implementing the Interceptor interface. In the intercept method, you check for the packet type and log the client id. HornetQ provides a simple example.

single jms consumer for multiple jms servers

I am using a distributed jms queue and weblogic is my app server. There are three jms servers deployed in my clustered enviroment. The producers just send the message using name of queue jndi lookup 'udq' for example. Now I have associated a consumer for each jms server and I was able to consume the message, no problem so far.
Here is question, can I have a single consumer to consume the messages from the 3 jms servers. The weblogic allows jndi naming for destination lookup with following syntax #
qsession1 = qcon1.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
qsession2 = qcon2.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
qsession3 = qcon3.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queue1 = (Queue)ctx.lookup("JMSServer-1#UDQ");
queue2 = (Queue)ctx.lookup("JMSServer-2#UDQ");
queue3 = (Queue)ctx.lookup("JMSServer-3#UDQ");
qreceiver1 = qsession1.createReceiver(queue1);
qreceiver2 = qsession2.createReceiver(queue2);
qreceiver3 = qsession3.createReceiver(queue3);
qreceiver1.setMessageListener(this);
qreceiver2.setMessageListener(this);
qreceiver3.setMessageListener(this);
qcon1.start();
qcon2.start();
qcon3.start();
I have only one OnMessage implemented for the above consumer. This does not work. Any suggestions please..
No, you can't have a consumer receiving messages from more than one JMS server. A consumer can receive messages from only one JMS server. You need to create multiple consumers to receive messages from multiple JMS servers.
you can use "Queue Forwarding" function.
From online documentation of wls 10.3:
"Queue members can forward messages to other queue members by configuring the Forward Delay attribute in the Administration Console, which is disabled by default. This attribute defines the amount of time, in seconds, that a distributed queue member with messages, but which has no consumers, will wait before forwarding its messages to other queue members that do have consumers."
here a link: http://docs.oracle.com/cd/E13222_01/wls/docs103/jms/dds.html#wp1260816
You can configure this feature from administration of each single queue.

Queue consumer clusters with ActiveMQ

How to configure cluster of Consumers in ActiveMQ?
I created a simple embedded ActiveMQ application with two consumers of one Queue, consumers are working in separate threads. But when I send a message to the Queue, JMS delivers it to first consumer no matter how long it sleeps after receiving.
I think you're trying to explain that the first consumer is receiving all the messages. There is a FAQ entry for this type of problem available here:
http://activemq.apache.org/i-do-not-receive-messages-in-my-second-consumer.html
Bruce

Resources