How to set the timeout value for the request method from the QueueRequestor class? There's a timeout parameter in the QueueReceiver .recieve() method, but none in QueueRequestor.request().

How to set the timeout value for the request method from the QueueRequestor class? There's a timeout parameter in the QueueReceiver .recieve() method, but none in QueueRequestor.request().

book

Article ID: KB0086759

calendar_today

Updated On:

Products Versions
TIBCO Enterprise Message Service -
Not Applicable -

Description

Resolution:
1. Here is an example of a QueueRequestor with a 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();
}
}


2. You can do the same for a TopicRequestor (replace Queue by Topic).

3. You can also do the same with  .NET API.

Issue/Introduction

How to set the timeout value for the request method from the QueueRequestor class? There's a timeout parameter in the QueueReceiver .recieve() method, but none in QueueRequestor.request().