2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the
7
* "License"); you may not use this file except in compliance
8
* with the License. You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing,
13
* software distributed under the License is distributed on an
14
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
* KIND, either express or implied. See the License for the
16
* specific language governing permissions and limitations
21
// This source code implements specifications defined by the Java
22
// Community Process. In order to remain compliant with the specification
23
// DO NOT add / change / or delete method signatures!
29
* @version $Rev: 467553 $ $Date: 2006-10-25 04:01:51 +0000 (mer 25 oct 2006) $
31
public class TopicRequestor {
32
private TopicSession session;
34
private TemporaryTopic temporaryTopic;
35
private TopicPublisher publisher;
36
private TopicSubscriber subscriber;
38
public TopicRequestor(TopicSession session, Topic topic)
43
setTemporaryTopic(session.createTemporaryTopic());
44
setPublisher(session.createPublisher(topic));
45
setSubscriber(session.createSubscriber(getTemporaryTopic()));
48
public Message request(Message message) throws JMSException {
49
message.setJMSReplyTo(getTemporaryTopic());
50
getPublisher().publish(message);
51
return (getSubscriber().receive());
54
public void close() throws JMSException {
56
getTemporaryTopic().delete();
59
private void setPublisher(TopicPublisher publisher) {
60
this.publisher = publisher;
63
private TopicPublisher getPublisher() {
67
private void setSession(TopicSession session) {
68
this.session = session;
71
private TopicSession getSession() {
75
private void setSubscriber(TopicSubscriber subscriber) {
76
this.subscriber = subscriber;
79
private TopicSubscriber getSubscriber() {
83
private void setTemporaryTopic(TemporaryTopic temporaryTopic) {
84
this.temporaryTopic = temporaryTopic;
87
private TemporaryTopic getTemporaryTopic() {
88
return temporaryTopic;
91
private void setTopic(Topic topic) {
95
private Topic getTopic() {