Source code: org/activemq/broker/BrokerClient.java
1 /**
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18
19 package org.activemq.broker;
20
21 import org.activemq.message.ActiveMQMessage;
22 import org.activemq.message.ConnectionInfo;
23 import org.activemq.service.Service;
24 import org.activemq.transport.TransportChannel;
25
26 import javax.jms.JMSException;
27 import javax.security.auth.Subject;
28
29 /**
30 * A Broker side proxy representing mostly outbound JMS Connnection
31 */
32
33 public interface BrokerClient extends Service {
34
35
36 /**
37 * Initialize the Brokerclient
38 *
39 * @param brokerConnector
40 * @param channel
41 */
42 public void initialize(BrokerConnector brokerConnector, TransportChannel channel);
43
44 /**
45 * Dispatch an ActiveMQMessage to the end client
46 *
47 * @param message
48 */
49 public void dispatch(ActiveMQMessage message);
50
51 /**
52 * @return true if the peer for this Client is itself another Broker
53 */
54 public boolean isBrokerConnection();
55
56 /**
57 * @return true id this client is part of a cluster
58 */
59 public boolean isClusteredConnection();
60
61
62 /**
63 * Get the Capacity for in-progress messages at the peer (probably a JMSConnection)
64 * Legimate values between 0-100. 0 capacity representing that the peer cannot process
65 * any more messages at the current time
66 *
67 * @return
68 */
69 public int getCapacity();
70
71
72 /**
73 * Get an indication if the peer should be considered as a slow consumer
74 *
75 * @return true id the peer should be considered as a slow consumer
76 */
77 public boolean isSlowConsumer();
78
79 /**
80 * Update the peer Connection about the Broker's capacity for messages
81 *
82 * @param capacity
83 */
84 public void updateBrokerCapacity(int capacity);
85
86 /**
87 * @return the client ID for this client if the client has been initialised
88 */
89 public String getClientID();
90
91 /**
92 * Called when the transport has been terminated, so do our best to
93 * shut down any resources and deregister from any subscriptions etc
94 */
95 public void cleanUp();
96
97 /**
98 * @return the TransportChannel
99 */
100 TransportChannel getChannel();
101
102 /**
103 * @return the BrokerConnector this client is associated with
104 */
105 public BrokerConnector getBrokerConnector();
106
107 /**
108 * Associcates a subject with BrokerClient.
109 */
110 public void setSubject(Subject subject);
111
112 /**
113 * @return the Subject associcates with the BrokerClient.
114 */
115 public Subject getSubject();
116
117 /**
118 * Tests the connection to assert that it in fact is alive by asserting that
119 * a full round-trip to the client is possible.
120 *
121 * @param timeout the number of millisecods to wait before the connection is declared invalid
122 * @throws JMSException if the connection is invalid
123 */
124 public void validateConnection(int timeout) throws JMSException;
125
126 /**
127 * @return the connection information for this client
128 */
129 public ConnectionInfo getConnectionInfo();
130 }