用delphi xe 开发rabbitmq应用(四)

2024-01-20 09:08
文章标签 应用 开发 rabbitmq delphi xe

本文主要是介绍用delphi xe 开发rabbitmq应用(四),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

读取死信队列

死信队列中的消息由系统自动增加了一些标识属性,x-death(是一个Array),x-first-death-exchange(queue/reason)。

死信队列中的消息如果不是由于异常(publisher代码控制)而进入,由于超时而进入,那其中的消息仍然可以正常读取(消费),只要代码中做特别处理。


   try
       //解码Header,如果从死信队列接收,其中还有 (x-death) Array
       with aMsg.Header.PropertyList.ApplicationHeaders do
       begin
           if IsFieldExist('x-death') then
           begin
                vDeath := Field['x-death'].AsArray;

                if vDeath.Items[0].kind = 'F' then
                begin
                   vTable := vDeath.Items[0].CastAsTable;
                   SiMain.LogInt64('TAsyncHello.DecodeMessage->count', vTable.FieldByName('count').Value.AsLongLongInt.Value);
                   SiMain.LogString('TAsyncHello.DecodeMessage->reason', vTable.StringByName('reason'));
                   SiMain.LogString('TAsyncHello.DecodeMessage->queue', vTable.StringByName('queue'));
                   SiMain.LogString('TAsyncHello.DecodeMessage->exchange', vTable.StringByName('exchange'));
                   //SiMain.LogString('x-first-death-exchange', vTable.StringByName('x-first-death-exchange'));

                end;
           end;
           if IsFieldExist('x-first-death-exchange') then
              SiMain.LogString('x-first-death-exchange', StringByName('x-first-death-exchange'));

           if IsFieldExist('x-first-death-queue') then
              SiMain.LogString('x-first-death-queue', StringByName('x-first-death-queue'));

           if IsFieldExist('x-first-death-reason') then
              SiMain.LogString('x-first-death-reason', StringByName('x-first-death-reason'));
       end;
   Except on E: Exception do
       begin
           siMain.LogException('解码消息头错误:' + E.Message);
           MainForm.MemoMessages.Lines.Add('解码消息头错误:' + E.Message);
       end;
   end;

   vMsgID := aMsg.Header.PropertyList.MessageID.Value;
   vAppID := aMsg.Header.PropertyList.AppID.Value;
   SiMain.LogString('AppID', aMsg.Header.PropertyList.AppID.Value);

   SiMain.LogInteger('TAsyncHello.DecodeMessage-->DeliveryMode', aMsg.Header.PropertyList.DeliveryMode.Value);
   SiMain.LogInteger('TAsyncHello.DecodeMessage-->Priority', aMsg.Header.PropertyList.Priority.Value);
   SiMain.LogString('TAsyncHello.DecodeMessage-->ContentType', aMsg.Header.PropertyList.ContentType.Value);
   //SiMain.LogString('Expiration', aMsg.Header.PropertyList.Expiration.Value);
   SiMain.LogString('TAsyncHello.DecodeMessage-->ContentEncoding', aMsg.Header.PropertyList.ContentEncoding.Value);
 

这篇关于用delphi xe 开发rabbitmq应用(四)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/625501

相关文章

基于 Cursor 开发 Spring Boot 项目详细攻略

《基于Cursor开发SpringBoot项目详细攻略》Cursor是集成GPT4、Claude3.5等LLM的VSCode类AI编程工具,支持SpringBoot项目开发全流程,涵盖环境配... 目录cursor是什么?基于 Cursor 开发 Spring Boot 项目完整指南1. 环境准备2. 创建

PHP应用中处理限流和API节流的最佳实践

《PHP应用中处理限流和API节流的最佳实践》限流和API节流对于确保Web应用程序的可靠性、安全性和可扩展性至关重要,本文将详细介绍PHP应用中处理限流和API节流的最佳实践,下面就来和小编一起学习... 目录限流的重要性在 php 中实施限流的最佳实践使用集中式存储进行状态管理(如 Redis)采用滑动

SpringBoot 多环境开发实战(从配置、管理与控制)

《SpringBoot多环境开发实战(从配置、管理与控制)》本文详解SpringBoot多环境配置,涵盖单文件YAML、多文件模式、MavenProfile分组及激活策略,通过优先级控制灵活切换环境... 目录一、多环境开发基础(单文件 YAML 版)(一)配置原理与优势(二)实操示例二、多环境开发多文件版

使用docker搭建嵌入式Linux开发环境

《使用docker搭建嵌入式Linux开发环境》本文主要介绍了使用docker搭建嵌入式Linux开发环境,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录1、前言2、安装docker3、编写容器管理脚本4、创建容器1、前言在日常开发全志、rk等不同

深入浅出Spring中的@Autowired自动注入的工作原理及实践应用

《深入浅出Spring中的@Autowired自动注入的工作原理及实践应用》在Spring框架的学习旅程中,@Autowired无疑是一个高频出现却又让初学者头疼的注解,它看似简单,却蕴含着Sprin... 目录深入浅出Spring中的@Autowired:自动注入的奥秘什么是依赖注入?@Autowired

RabbitMQ 延时队列插件安装与使用示例详解(基于 Delayed Message Plugin)

《RabbitMQ延时队列插件安装与使用示例详解(基于DelayedMessagePlugin)》本文详解RabbitMQ通过安装rabbitmq_delayed_message_exchan... 目录 一、什么是 RabbitMQ 延时队列? 二、安装前准备✅ RabbitMQ 环境要求 三、安装延时队

Python实战之SEO优化自动化工具开发指南

《Python实战之SEO优化自动化工具开发指南》在数字化营销时代,搜索引擎优化(SEO)已成为网站获取流量的重要手段,本文将带您使用Python开发一套完整的SEO自动化工具,需要的可以了解下... 目录前言项目概述技术栈选择核心模块实现1. 关键词研究模块2. 网站技术seo检测模块3. 内容优化分析模

PostgreSQL简介及实战应用

《PostgreSQL简介及实战应用》PostgreSQL是一种功能强大的开源关系型数据库管理系统,以其稳定性、高性能、扩展性和复杂查询能力在众多项目中得到广泛应用,本文将从基础概念讲起,逐步深入到高... 目录前言1. PostgreSQL基础1.1 PostgreSQL简介1.2 基础语法1.3 数据库

基于Java开发一个极简版敏感词检测工具

《基于Java开发一个极简版敏感词检测工具》这篇文章主要为大家详细介绍了如何基于Java开发一个极简版敏感词检测工具,文中的示例代码简洁易懂,感兴趣的小伙伴可以跟随小编一起学习一下... 目录你是否还在为敏感词检测头疼一、极简版Java敏感词检测工具的3大核心优势1.1 优势1:DFA算法驱动,效率提升10

spring AMQP代码生成rabbitmq的exchange and queue教程

《springAMQP代码生成rabbitmq的exchangeandqueue教程》使用SpringAMQP代码直接创建RabbitMQexchange和queue,并确保绑定关系自动成立,简... 目录spring AMQP代码生成rabbitmq的exchange and 编程queue执行结果总结s