Class: Qpid::Proton::Receiver

Inherits:
Link show all
Includes:
Util::SwigHelper
Defined in:
lib/core/receiver.rb

Overview

The receiving endpoint.

See Also:

Constant Summary collapse

PROTON_METHOD_PREFIX =
"pn_link"

Constants inherited from Link

Link::RCV_FIRST, Link::RCV_SECOND, Link::SND_MIXED, Link::SND_SETTLED, Link::SND_UNSETTLED

Constants inherited from Endpoint

Endpoint::LOCAL_ACTIVE, Endpoint::LOCAL_CLOSED, Endpoint::LOCAL_MASK, Endpoint::LOCAL_UNINIT, Endpoint::REMOTE_ACTIVE, Endpoint::REMOTE_CLOSED, Endpoint::REMOTE_MASK, Endpoint::REMOTE_UNINIT

Instance Attribute Summary collapse

Attributes inherited from Link

#available, #credit, #name, #queued, #receiver?, #remote_credit, #sender?, #state

Instance Method Summary collapse

Methods included from Util::SwigHelper

included

Methods inherited from Link

#==, #_local_condition, #_remote_condition, #advance, #close, #connection, #current, #delivery, #detach, #drained, #error, #initialize, #next, #open, #rcv_settle_mode, #rcv_settle_mode=, #remote_source, #remote_target, #session, #snd_settle_mode, #snd_settle_mode=, #source, #target, wrap

Methods included from Util::Wrapper

#impl, #impl=, included, registry

Methods inherited from Endpoint

#_update_condition, #check_state, #handler, #handler=, #initialize, #local_active?, #local_closed?, #local_uninit?, #remote_active?, #remote_closed?, #remote_condition, #remote_uninit?, #transport

Methods included from Util::Engine

#condition_to_object, #data_to_object, #object_to_condition, #object_to_data, receive_message

Constructor Details

This class inherits a constructor from Qpid::Proton::Link

Instance Attribute Details

#drainBoolean

The drain mode.

If a receiver is in drain mode, then the sending endpoint of a link must immediately use up all available credit on the link. If this is not possible, the excess credit must be returned by invoking #drained.

Only the receiving endpoint can set the drain mode.

Returns:

  • (Boolean)

    True if drain mode is set.



46
# File 'lib/core/receiver.rb', line 46

proton_accessor :drain

#draining?Boolean (readonly)

Returns if a link is currently draining.

A link is defined to be draining when drain mode is set to true and the sender still has excess credit.

Returns:

  • (Boolean)

    True if the receiver is currently draining.



57
# File 'lib/core/receiver.rb', line 57

proton_caller :draining?

Instance Method Details

#flow(n) ⇒ Object

Grants credit for incoming deliveries.

Parameters:

  • n (Fixnum)

    The amount to increment the link credit.



63
64
65
# File 'lib/core/receiver.rb', line 63

def flow(n)
  Cproton.pn_link_flow(@impl, n)
end

#receive(limit) ⇒ Fixnum?

Allows receiving up to the specified limit of data from the remote endpoint.

Note that large messages can be streamed across the network, so just because there is no data to read does not imply the message is complete.

To ensure the entirety of the message data has been read, either call #receive until nil is returned, or verify that #partial? is false and Delivery#pending is 0.

the stream was reached.t

Parameters:

  • limit (Fixnum)

    The maximum bytes to receive.

Returns:

  • (Fixnum, nil)

    The number of bytes received, or nil if the end of

Raises:

See Also:

  • To see how much buffer space is needed.


86
87
88
89
90
91
# File 'lib/core/receiver.rb', line 86

def receive(limit)
  (n, bytes) = Cproton.pn_link_recv(@impl, limit)
  return nil if n == Qpid::Proton::Error::EOS
  raise LinkError.new("[#{n}]: #{Cproton.pn_link_error(@impl)}") if n < 0
  return bytes
end