2009-10-19 4 views
2

응답을위한 임시 대기열을 생성해야하지만 응답 스레드가 해당 객체를 전혀 얻지 못하기 때문에 메시지의 setJMSReplyTo 메소드를 통해 응답 대기열 객체를 보내지 않고 임시 대기열에 연결할 수 있는지 알아야합니다.임시 jms 대기열을 작성하고 이름으로 연결하는 방법은 무엇입니까?

+1

답변을 실제 답변으로 게시하고 동의하십시오. 그렇지 않으면 귀하의 질문은 항상 "답변되지 않은"범주에있게되며 실제로 응답 할 때 혼란 스러울 것입니다. –

답변

2

임시 대기열을 사용해야하는 스레드에서 임시 대기열을 조회 할 수 있도록 InitialContext 객체를 사용하여 임시 대기열을 jndi에 바인드했습니다.

jndiContext = new InitialContext(); 
connectionFactory = (QueueConnectionFactory) jndiContext.lookup("ConnectionFactory"); 
connection = connectionFactory.createConnection(); 
connection.start(); 
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); 
temporaryQueue = session.createTemporaryQueue();  
jndiContext.bind(queueJndiName, temporaryQueue);  
destination = temporaryQueue; 
responseConsumer = session.createConsumer(destination); 
responseConsumer.setMessageListener(new MyListener()); 

당신이 그것을 사용할 필요가 어디 그냥 코드에서 조회 할 필요가 일시적으로 큐를 효율적으로 활용하려면 다음

Context jndiContext = new InitialContext(); 
queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("ConnectionFactory"); 
queue = (Queue) jndiContext.lookup(youTemporaryQueueName);  
-1
asadmin> create-jms-resource --restype javax.jms.ConnectionFactory --description "connection factory for XXX" jms/ConnectionFactory 



asadmin> create-jms-resource --restype javax.jms.ConnectionFactory --description "connection factory for durable subscriptions" 
--property ClientId=MyID jms/DurableConnectionFactory 

명령 생성 - JMS-자원이 성공적으로 실행되었습니다.

glassfish server.it에서와 같이 성공적으로 생성됩니다.

관련 문제