Hi there,
for some time I am trying to find a way I could connect through JMS
session bean and remote client using temporary queue. This is how I
think it should be done:
//// CONSUMER SIDE:
QueueConnection qc = queueConnectionFactory.createQueueConnection();
QueueSession qSession = qc.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
TemporaryQueue tempQueue = qSession.createTemporaryQueue();
MessageConsumer consumer = qSession.createConsumer(tempQueue);
someRemoteSession.sender(tempQueue);
qc.start();
TextMessage message = (TextMessage) consumer.receive();
System.out.println(message.getText();
qc.close();
//// PRODUCER SIDE, remote interface:
public void sender(TemporaryQueue queue) {
QueueConnection qc = queueConnectionFactory.createQueueConnection();
QueueSession session = qc.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
Message message = session.createTextMessage("Hello message");
producer.send(message);
qc.close();
}
The problem here is that Queue/TemporaryQueue implementations are not
serializable, so I cannot pass queue as a parameter. I was trying to
send something else as we have more options here, but neither
QueueSession nor MessageProducer implementations are Serializable, so
I cannot create them in my consumer and share with producer.
My question is: HOW I can use temporary queues? How can I prepare
producer and consumer that are remote to each other if nothing is
Serializable here?
Can you help me? I cannot find answer for 3 days so far :(