Thank you for your suggestion Nageswara.
In fact I would like to not even receive this message in the onMessage
callback function... because if I the receiving thread executes the
doWaitLogic() you propose, then I can not receive any message from any
other queue associated with this MessageListener.
Basically I would like to know if there is a solution to this "Receiver
Flow Control" problem without using a pool of application threads.
Any other comment is more than welcome,
Thank you,
Sylvain
On 3/31/2011 18:12, Nakarikanti, Nageswara wrote:
I do not know this is the best / good one, But I got an Idea.
1. Create a new JMS Message by setting its JMS Type (abstract public void
setJMSType(String org) throws javax.jms.JMSException) like 'WAIT_FOR_SOME_TIME'.
2. In Your ProjectConstants program (if any, other wise a global constant)
create a string constant JMS_MSG_TYPE_WAIT = WAIT_FOR_SOME_TIME.
3. In onMessage
public void onMessage(Message message) {
try {
if
(ProjectConstants.JMS_MSG_TYPE_WAIT.equals(message.getJMSType())) {
doWaitLogic();
}
else if (message instanceof TextMessage//or
some other JMS Message Type) {
doBusiness(message)
}
} catch (JMSException e) {
logger.error("JMSException", e);
}
}
Thank You,
Nag.
-----Original Message-----
From: Sylvain Vittecoq [mailto:[email protected]]
Sent: Thursday, March 31, 2011 5:06 AM
To: [email protected]
Cc: [email protected]
Subject: How to disable consumption from one queue "temporarily" ?
Hello all,
We are using ActiveMQ 5.4.2 with the activemq-cpp library 3.2.4.
Our topology is the following :
* A set of Linux processes (consuming and producing messages) are
connected to a Broker A.
* Another set of Linux processes (consuming and producing messages)
are connected to a Broker B.
* Broker A and Broker B are connected to each other.
We have activated the producer flow control on all queues (we do not use topics
at this point) and all our messages are non-persistent messages.
I believe this is the only deviance from the default configuration.
My question is the following :
Each process may consume messages from different queues.
What is the "best" way for such consumer to indicate that it does not want to
receive any new message from a specific queue ?
(But this consumer must keep receiving messages posted on its other queues).
One solution seems to clear the MessageListener for this specific Consumer :
/getConsumer()->*setMessageListener*(NULL);
/
to not receive any message and then later on set again the
MessageListener when the processing can resume for this queue inside
this process:
/getConsummer()->*setMessageListener*(this);
/
However in our environment it seems that the /*setMessageListener()
API*/ must be executed by a thread which can NOT be the ActiveMQ thread
calling the onMessage callback function.
So is there an easier solution which does not require this extra
application thread ?
Thank you very much for your help,
Sylvain
--
Sylvain Vittecoq
Cell : +46 (0) 7 67 77 76 10
SkypeId: sylvainvittecoq
Web: http://www.byteactive.com