AMQP1 | Read Message

Every time a new message is received, the event OnAMQPMessage is fired.

 

The TsgcAMQP1Message instance contains the message received. You can access to the text message using the property aMessage.ApplicationData.AMQPValue.Value.

 

To specify the Delivery Outcome, use the DeliveryState parameter. By default, all the messages have the accepted state, but you can set one of the following:

 

 


procedure OnAMQPMessage(Sender: TObject;
const aSession: TsgcAMQP1Session; const aLink: TsgcAMQP1ReceiverLink;
const aMessage: TsgcAMQP1Message;
var DeliveryState: TsgcAMQP1MessageDeliveryState);
begin
  if aMessage.ApplicationData.AMQPValue.Value = 'xxx' then
  begin
    DeliveryState.State := amqp1mdtsRejected;
    DeliveryState.Rejected.Error.Condition := 'amqp-error-processing';
    DeliveryState.Rejected.Error.Description := 'Value received was not the expected.';
  end
  else
    DeliveryState.State := amqp1mdtsAccepted;
end;