| 1 |
# Licensed to the Apache Software Foundation (ASF) under one |
| 2 |
# or more contributor license agreements. See the NOTICE file |
| 3 |
# distributed with this work for additional information |
| 4 |
# regarding copyright ownership. The ASF licenses this file |
| 5 |
# to you under the Apache License, Version 2.0 (the |
| 6 |
# "License"); you may not use this file except in compliance |
| 7 |
# with the License. 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, |
| 12 |
# software distributed under the License is distributed on an |
| 13 |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 |
# KIND, either express or implied. See the License for the |
| 15 |
# specific language governing permissions and limitations |
| 16 |
# under the License. |
| 17 |
|
| 18 |
|
| 19 |
module Qpid::Proton |
| 20 |
|
| 21 |
# A handler for AMQP messaging events. |
| 22 |
# |
| 23 |
# Subclass the handler and provide the #on_xxx methods with your event-handling code. |
| 24 |
# |
| 25 |
# An AMQP endpoint (connection, session or link) must be opened and closed at |
| 26 |
# each end. Normally proton responds automatically to an incoming |
| 27 |
# open/close. You can prevent the automatic response by raising |
| 28 |
# {StopAutoResponse} from +#on_xxx_open+ or +#on_xxx_close+. The application becomes responsible |
| 29 |
# for calling +#open/#close+ at a later point. |
| 30 |
# |
| 31 |
# *Note*: If a {MessagingHandler} method raises an exception, it will stop the {Container} |
| 32 |
# that the handler is running in. See {Container#run} |
| 33 |
# |
| 34 |
class MessagingHandler |
| 35 |
|
| 36 |
# @return [Hash] handler options, see {#initialize} |
| 37 |
attr_reader :options |
| 38 |
|
| 39 |
# @!group Most common events |
| 40 |
|
| 41 |
# @!method on_container_start(container) |
| 42 |
# The container event loop is started |
| 43 |
# @param container [Container] The container. |
| 44 |
|
| 45 |
# @!method on_container_stop(container) |
| 46 |
# The container event loop is stopped |
| 47 |
# @param container [Container] The container. |
| 48 |
|
| 49 |
# @!method on_message(delivery, message) |
| 50 |
# A message is received. |
| 51 |
# @param delivery [Delivery] The delivery. |
| 52 |
# @param message [Message] The message |
| 53 |
|
| 54 |
# @!method on_sendable(sender) |
| 55 |
# A message can be sent |
| 56 |
# @param sender [Sender] The sender. |
| 57 |
|
| 58 |
# @!endgroup |
| 59 |
|
| 60 |
# @!group Endpoint lifecycle events |
| 61 |
|
| 62 |
# @!method on_connection_open(connection) |
| 63 |
# The remote peer opened the connection |
| 64 |
# @param connection |
| 65 |
|
| 66 |
# @!method on_connection_close(connection) |
| 67 |
# The remote peer closed the connection |
| 68 |
# @param connection |
| 69 |
|
| 70 |
# @!method on_connection_error(connection) |
| 71 |
# The remote peer closed the connection with an error condition |
| 72 |
# @param connection |
| 73 |
|
| 74 |
# @!method on_session_open(session) |
| 75 |
# The remote peer opened the session |
| 76 |
# @param session |
| 77 |
|
| 78 |
# @!method on_session_close(session) |
| 79 |
# The remote peer closed the session |
| 80 |
# @param session |
| 81 |
|
| 82 |
# @!method on_session_error(session) |
| 83 |
# The remote peer closed the session with an error condition |
| 84 |
# @param session |
| 85 |
|
| 86 |
# @!method on_sender_open(sender) |
| 87 |
# The remote peer opened the sender |
| 88 |
# @param sender |
| 89 |
|
| 90 |
# @!method on_sender_detach(sender) |
| 91 |
# The remote peer detached the sender |
| 92 |
# @param sender |
| 93 |
|
| 94 |
# @!method on_sender_close(sender) |
| 95 |
# The remote peer closed the sender |
| 96 |
# @param sender |
| 97 |
|
| 98 |
# @!method on_sender_error(sender) |
| 99 |
# The remote peer closed the sender with an error condition |
| 100 |
# @param sender |
| 101 |
|
| 102 |
# @!method on_receiver_open(receiver) |
| 103 |
# The remote peer opened the receiver |
| 104 |
# @param receiver |
| 105 |
|
| 106 |
# @!method on_receiver_detach(receiver) |
| 107 |
# The remote peer detached the receiver |
| 108 |
# @param receiver |
| 109 |
|
| 110 |
# @!method on_receiver_close(receiver) |
| 111 |
# The remote peer closed the receiver |
| 112 |
# @param receiver |
| 113 |
|
| 114 |
# @!method on_receiver_error(receiver) |
| 115 |
# The remote peer closed the receiver with an error condition |
| 116 |
# @param receiver |
| 117 |
|
| 118 |
# @!endgroup |
| 119 |
|
| 120 |
# @!group Delivery events |
| 121 |
|
| 122 |
# @!method on_tracker_accept(tracker) |
| 123 |
# The receiving end accepted a delivery |
| 124 |
# @param tracker [Tracker] The tracker. |
| 125 |
|
| 126 |
# @!method on_tracker_reject(tracker) |
| 127 |
# The receiving end rejected a delivery |
| 128 |
# @param tracker [Tracker] The tracker. |
| 129 |
|
| 130 |
# @!method on_tracker_release(tracker) |
| 131 |
# The receiving end released a delivery |
| 132 |
# @param tracker [Tracker] The tracker. |
| 133 |
|
| 134 |
# @!method on_tracker_modify(tracker) |
| 135 |
# The receiving end modified a delivery |
| 136 |
# @param tracker [Tracker] The tracker. |
| 137 |
|
| 138 |
# @!method on_tracker_settle(tracker) |
| 139 |
# The receiving end settled a delivery |
| 140 |
# @param tracker [Tracker] The tracker. |
| 141 |
|
| 142 |
# @!method on_delivery_settle(delivery) |
| 143 |
# The sending end settled a delivery |
| 144 |
# @param delivery [Delivery] The delivery. |
| 145 |
|
| 146 |
# @!method on_delivery_abort(delivery) |
| 147 |
# A message was begun but aborted by the sender, so was not received. |
| 148 |
# @param delivery [Delivery] The delivery. |
| 149 |
|
| 150 |
# @!endgroup |
| 151 |
|
| 152 |
# @!group Flow control events |
| 153 |
|
| 154 |
# @!method on_sender_drain_start(sender) |
| 155 |
# The remote end of the sender requested draining |
| 156 |
# @param sender [Sender] The sender. |
| 157 |
|
| 158 |
# @!method on_receiver_drain_finish(receiver) |
| 159 |
# The remote end of the receiver completed draining |
| 160 |
# @param receiver [Receiver] The receiver. |
| 161 |
|
| 162 |
# @!endgroup |
| 163 |
|
| 164 |
# @!group Transport events |
| 165 |
|
| 166 |
# @!method on_transport_open(transport) |
| 167 |
# The underlying network channel opened |
| 168 |
# @param transport [Transport] The transport. |
| 169 |
|
| 170 |
# @!method on_transport_close(transport) |
| 171 |
# The underlying network channel closed |
| 172 |
# @param transport [Transport] The transport. |
| 173 |
|
| 174 |
# @!method on_transport_error(transport) |
| 175 |
# The underlying network channel is closing due to an error. |
| 176 |
# @param transport [Transport] The transport. |
| 177 |
|
| 178 |
# @!endgroup |
| 179 |
|
| 180 |
# @!group Unhandled events |
| 181 |
|
| 182 |
# @!method on_error(error_condition) |
| 183 |
# Called on an error if no more specific on_xxx_error method is provided. |
| 184 |
# If on_error() is also not defined, the connection is closed with error_condition |
| 185 |
# @param error_condition [Condition] Provides information about the error. |
| 186 |
|
| 187 |
# @!method on_unhandled(method_name, *args) |
| 188 |
# Called for events with no handler. Similar to ruby's standard #method_ |
| 189 |
# @param method_name [Symbol] Name of the event method that would have been called. |
| 190 |
# @param args [Array] Arguments that would have been passed |
| 191 |
|
| 192 |
# @!endgroup |
| 193 |
end |
| 194 |
end |