Class: PulsarSdk::Protocol::Message
- Inherits:
-
Object
- Object
- PulsarSdk::Protocol::Message
- Includes:
- Tweaks::AssignAttributes, Tweaks::CleanInspect
- Defined in:
- lib/pulsar_sdk/protocol/message.rb
Instance Attribute Summary collapse
-
#ack_handler ⇒ Object
Returns the value of attribute ack_handler.
-
#consumer_id ⇒ Object
Returns the value of attribute consumer_id.
-
#event_time ⇒ Object
Returns the value of attribute event_time.
-
#message_id ⇒ Object
Returns the value of attribute message_id.
-
#partition_key ⇒ Object
Returns the value of attribute partition_key.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#publish_time ⇒ Object
Returns the value of attribute publish_time.
-
#topic ⇒ Object
Returns the value of attribute topic.
Instance Method Summary collapse
- #ack(type = Pulsar::Proto::CommandAck::AckType::Individual) ⇒ Object
-
#confirmed? ⇒ Boolean
检查是否有确认,无论是ack还是nack都算是确认.
- #nack ⇒ Object
Methods included from Tweaks::AssignAttributes
#assign_attributes, #initialize
Methods included from Tweaks::CleanInspect
Instance Attribute Details
#ack_handler ⇒ Object
Returns the value of attribute ack_handler.
10 11 12 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 10 def ack_handler @ack_handler end |
#consumer_id ⇒ Object
Returns the value of attribute consumer_id.
7 8 9 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 7 def consumer_id @consumer_id end |
#event_time ⇒ Object
Returns the value of attribute event_time.
7 8 9 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 7 def event_time @event_time end |
#message_id ⇒ Object
Returns the value of attribute message_id.
7 8 9 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 7 def @message_id end |
#partition_key ⇒ Object
Returns the value of attribute partition_key.
7 8 9 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 7 def partition_key @partition_key end |
#payload ⇒ Object
Returns the value of attribute payload.
7 8 9 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 7 def payload @payload end |
#properties ⇒ Object
Returns the value of attribute properties.
7 8 9 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 7 def properties @properties end |
#publish_time ⇒ Object
Returns the value of attribute publish_time.
7 8 9 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 7 def publish_time @publish_time end |
#topic ⇒ Object
Returns the value of attribute topic.
7 8 9 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 7 def topic @topic end |
Instance Method Details
#ack(type = Pulsar::Proto::CommandAck::AckType::Individual) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 22 def ack(type = Pulsar::Proto::CommandAck::AckType::Individual) base_cmd = Pulsar::Proto::BaseCommand.new( type: Pulsar::Proto::BaseCommand::Type::ACK, ack: Pulsar::Proto::CommandAck.new( consumer_id: self.consumer_id, message_id: [self.], ack_type: type ) ) ack_handler.call(base_cmd) @confirmed = true end |
#confirmed? ⇒ Boolean
检查是否有确认,无论是ack还是nack都算是确认
37 38 39 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 37 def confirmed? !!@confirmed end |
#nack ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pulsar_sdk/protocol/message.rb', line 41 def nack base_cmd = Pulsar::Proto::BaseCommand.new( type: Pulsar::Proto::BaseCommand::Type::REDELIVER_UNACKNOWLEDGED_MESSAGES, redeliverUnacknowledgedMessages: Pulsar::Proto::CommandRedeliverUnacknowledgedMessages.new( consumer_id: self.consumer_id, message_ids: [self.] ) ) ack_handler.call(base_cmd) @confirmed = true end |