Products | Versions |
---|---|
TIBCO Enterprise Message Service | - |
Not Applicable | - |
Resolution:
According to JMS standard, QueueRequestor and TopicRequestor do not have timeout parameter.
Therefore, You have to handle the situation using your own code.
Please find here below a java example of a QueueRequestor with a JAVA request() method that accept a timeout value:
class QueueRequestor
{
QueueSession session; // The queue session the queue belongs to.
Queue queue; // The queue to perform the request/reply
on.
TemporaryQueue tempQueue;
QueueSender sender;
QueueReceiver receiver;
public QueueRequestor(QueueSession session, Queue queue) throws
JMSException
{
this.session = session;
this.queue = queue;
tempQueue = session.createTemporaryQueue();
sender = session.createSender(queue);
receiver = session.createReceiver(tempQueue);
}
public Message request(Message message, long timeout) throws
JMSException
{
message.setJMSReplyTo(tempQueue);
sender.send(message);
return (receiver.receive(timeout));
}
public Message request(Message message) throws JMSException
{
return request(message, 0);
}
public void close() throws JMSException
{
receiver.close();
tempQueue.delete();
session.close();
}
}
You can also code your C code for setting up the timeout value.
To sum up, you create a temporary Queue and set this temporary queue as reply Queue, then create receiver( setting timeout value) for the temporary Queue.
The receiver will receive replied messages from the temporary Queue within the timeout period.
In alternative, You could use a QueueSender and a QueueReceiver, then use Consumer_ReceiveTimeout
and set TimeToLive in the sender.