001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.activemq.transport.amqp.protocol; 018 019import org.apache.activemq.command.ActiveMQDestination; 020import org.apache.qpid.proton.amqp.transport.ErrorCondition; 021import org.apache.qpid.proton.engine.Delivery; 022 023/** 024 * Interface used to define the operations needed to implement an AMQP 025 * Link based endpoint, i.e. Sender, Receiver or Coordinator. 026 */ 027public interface AmqpLink extends AmqpResource { 028 029 /** 030 * Close the Link with an error indicating the reson for the close. 031 * 032 * @param error 033 * the error that prompted the close. 034 */ 035 void close(ErrorCondition error); 036 037 /** 038 * Request from the remote peer to detach this resource. 039 */ 040 void detach(); 041 042 /** 043 * Handles an incoming flow control. 044 * 045 * @throws Excption if an error occurs during the flow processing. 046 */ 047 void flow() throws Exception; 048 049 /** 050 * Called when a new Delivery arrives for the given Link. 051 * 052 * @param delivery 053 * the newly arrived delivery on this link. 054 * 055 * @throws Exception if an error occurs while processing the new Delivery. 056 */ 057 void delivery(Delivery delivery) throws Exception; 058 059 /** 060 * Handle work necessary on commit of transacted resources associated with 061 * this Link instance. 062 * 063 * @throws Exception if an error occurs while performing the commit. 064 */ 065 void commit() throws Exception; 066 067 /** 068 * Handle work necessary on rollback of transacted resources associated with 069 * this Link instance. 070 * 071 * @throws Exception if an error occurs while performing the rollback. 072 */ 073 void rollback() throws Exception; 074 075 /** 076 * @return the ActiveMQDestination that this link is servicing. 077 */ 078 public ActiveMQDestination getDestination(); 079 080 /** 081 * Sets the ActiveMQDestination that this link will be servicing. 082 * 083 * @param destination 084 * the ActiveMQDestination that this link services. 085 */ 086 public void setDestination(ActiveMQDestination destination); 087 088 /** 089 * Adds a new Runnable that is called on close of this link. 090 * 091 * @param action 092 * a Runnable that will be executed when the link closes or detaches. 093 */ 094 public void addCloseAction(Runnable action); 095 096}