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 package org.codehaus.activemq.broker; 19 20 import org.codehaus.activemq.capacity.CapacityMonitor; 21 import org.codehaus.activemq.message.ActiveMQMessage; 22 import org.codehaus.activemq.message.ActiveMQXid; 23 import org.codehaus.activemq.message.ConsumerInfo; 24 import org.codehaus.activemq.message.MessageAck; 25 import org.codehaus.activemq.service.Service; 26 import org.codehaus.activemq.store.PersistenceAdapter; 27 28 import javax.jms.JMSException; 29 import javax.transaction.xa.XAException; 30 import java.io.File; 31 32 /*** 33 * The Message Broker which routes messages, 34 * maintains subscriptions and connections, acknowlegdges messages and handles 35 * transactions. 36 * 37 * @version $Revision: 1.7 $ 38 */ 39 public interface Broker extends Service, CapacityMonitor { 40 41 /*** 42 * Add an active message consumer 43 * 44 * @param client 45 * @param info 46 * @throws JMSException 47 */ 48 public void addMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException; 49 50 /*** 51 * remove an active message consumer 52 * 53 * @param client 54 * @param info 55 * @throws JMSException 56 */ 57 public void removeMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException; 58 59 /*** 60 * gets a list of all the prepared xa transactions. 61 * 62 * @param client 63 */ 64 public ActiveMQXid[] getPreparedTransactions(BrokerClient client) throws XAException; 65 66 /*** 67 * Acknowledge consumption of a message by the Message Consumer 68 * 69 * @param client 70 * @param ack 71 * @throws JMSException 72 */ 73 public void acknowledgeMessage(BrokerClient client, MessageAck ack) throws JMSException; 74 75 /*** 76 * Acknowledge consumption of a message within a transaction 77 * 78 * @param client 79 * @param transactionId 80 * @param ack 81 * @throws JMSException 82 */ 83 public void acknowledgeTransactedMessage(BrokerClient client, String transactionId, MessageAck ack) throws JMSException; 84 85 86 /*** 87 * Called after a rollback of a JMS transaction to redeliver the message to the consumers 88 * dispatch queue 89 * 90 * @param client 91 * @param ack 92 */ 93 public void redeliverMessage(BrokerClient client, MessageAck ack) throws JMSException; 94 95 /*** 96 * send a message to the broker 97 * 98 * @param client 99 * @param message 100 * @throws JMSException 101 */ 102 public void sendMessage(BrokerClient client, ActiveMQMessage message) throws JMSException; 103 104 /*** 105 * send a message to the broker within a transaction 106 * 107 * @param client 108 * @param transactionId 109 * @param message 110 * @throws JMSException 111 */ 112 public void sendTransactedMessage(BrokerClient client, String transactionId, ActiveMQMessage message) throws JMSException; 113 114 /*** 115 * A hint to the broker that an BrokerClient has stopped 116 * This enables the broker to clean-up any outstanding processing 117 * that may be outstanding 118 * 119 * @param client 120 * @throws JMSException 121 */ 122 public void cleanUpClient(BrokerClient client) throws JMSException; 123 124 /*** 125 * Delete a durable subscriber 126 * 127 * @param clientId 128 * @param subscriberName 129 * @throws JMSException if the subscriber doesn't exist or is still active 130 */ 131 public void deleteSubscription(String clientId, String subscriberName) throws JMSException; 132 133 /*** 134 * start a transaction 135 * 136 * @param client 137 * @param transactionId 138 */ 139 public void startTransaction(BrokerClient client, String transactionId) throws JMSException; 140 141 /*** 142 * commit a transaction 143 * 144 * @param client 145 * @param transactionId 146 * @throws JMSException 147 */ 148 public void commitTransaction(BrokerClient client, String transactionId) throws JMSException; 149 150 /*** 151 * rollback a transaction 152 * 153 * @param client 154 * @param transactionId 155 * @throws JMSException 156 */ 157 public void rollbackTransaction(BrokerClient client, String transactionId) throws JMSException; 158 159 160 /*** 161 * @param client 162 * @param xid 163 */ 164 public void startTransaction(BrokerClient client, ActiveMQXid xid) throws XAException; 165 166 /*** 167 * @param client 168 * @param xid 169 */ 170 public int prepareTransaction(BrokerClient client, ActiveMQXid xid) throws XAException; 171 172 /*** 173 * @param client 174 * @param xid 175 */ 176 public void rollbackTransaction(BrokerClient client, ActiveMQXid xid) throws XAException; 177 178 /*** 179 * @param client 180 * @param xid 181 * @param onePhase 182 */ 183 public void commitTransaction(BrokerClient client, ActiveMQXid xid, boolean onePhase) throws XAException; 184 185 /*** 186 * Get a temp directory - used for spooling 187 * 188 * @return a File ptr to the directory 189 */ 190 public File getTempDir(); 191 192 public String getBrokerName(); 193 194 PersistenceAdapter getPersistenceAdapter(); 195 196 void setPersistenceAdapter(PersistenceAdapter persistenceAdapter); 197 }