KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > command > ProducerInfo


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.command;
19
20 import org.apache.activemq.state.CommandVisitor;
21
22 /**
23  *
24  * @openwire:marshaller code="6"
25  * @version $Revision: 1.13 $
26  */

27 public class ProducerInfo extends BaseCommand {
28
29     public static final byte DATA_STRUCTURE_TYPE=CommandTypes.PRODUCER_INFO;
30
31     protected ProducerId producerId;
32     protected ActiveMQDestination destination;
33     protected BrokerId[] brokerPath;
34     protected boolean dispatchAsync;
35     protected int windowSize;
36     
37     public ProducerInfo() {
38     }
39
40     public ProducerInfo(ProducerId producerId) {
41         this.producerId = producerId;
42     }
43
44     public ProducerInfo(SessionInfo sessionInfo, long producerId) {
45         this.producerId = new ProducerId(sessionInfo.getSessionId(), producerId);
46     }
47
48     public ProducerInfo copy() {
49         ProducerInfo info = new ProducerInfo();
50         copy(info);
51         return info;
52     }
53
54     public void copy(ProducerInfo info) {
55         super.copy(info);
56         info.producerId = producerId;
57         info.destination = destination;
58     }
59
60     public byte getDataStructureType() {
61         return DATA_STRUCTURE_TYPE;
62     }
63     
64     /**
65      * @openwire:property version=1 cache=true
66      */

67     public ProducerId getProducerId() {
68         return producerId;
69     }
70     public void setProducerId(ProducerId producerId) {
71         this.producerId = producerId;
72     }
73     
74     /**
75      * @openwire:property version=1 cache=true
76      */

77     public ActiveMQDestination getDestination() {
78         return destination;
79     }
80     public void setDestination(ActiveMQDestination destination) {
81         this.destination = destination;
82     }
83     
84     public RemoveInfo createRemoveCommand() {
85         RemoveInfo command = new RemoveInfo(getProducerId());
86         command.setResponseRequired(isResponseRequired());
87         return command;
88     }
89     
90     /**
91      * The route of brokers the command has moved through.
92      *
93      * @openwire:property version=1 cache=true
94      */

95     public BrokerId[] getBrokerPath() {
96         return brokerPath;
97     }
98     public void setBrokerPath(BrokerId[] brokerPath) {
99         this.brokerPath = brokerPath;
100     }
101
102     public Response visit(CommandVisitor visitor) throws Exception JavaDoc {
103         return visitor.processAddProducer( this );
104     }
105
106     /**
107      * If the broker should dispatch messages from this producer async. Since sync
108      * dispatch could potentally block the producer thread, this could be an important
109      * setting for the producer.
110      *
111      * @openwire:property version=2
112      */

113     public boolean isDispatchAsync() {
114         return dispatchAsync;
115     }
116
117     public void setDispatchAsync(boolean dispatchAsync) {
118         this.dispatchAsync = dispatchAsync;
119     }
120
121     /**
122      * Used to configure the producer window size. A producer will
123      * send up to the configured window size worth of payload data to
124      * the broker before waiting for an Ack that allows him to send more.
125      *
126      * @openwire:property version=3
127      */

128     public int getWindowSize() {
129         return windowSize;
130     }
131
132     public void setWindowSize(int windowSize) {
133         this.windowSize = windowSize;
134     }
135
136 }
137
Popular Tags