当前位置:网站首页>IBM WebSphere MQ检索邮件
IBM WebSphere MQ检索邮件
2022-07-04 17:10:00 【用户7741497】
IBM WebSphere MQ检索邮件
检索邮件
要检索邮件,请执行以下操作:
- 按照“创建连接对象”中的说明创建连接对象。在这种情况下,请创建
%Net.MQRecv
的实例。Connection
对象有一个消息队列,可以从中检索消息。 - 根据需要调用以下方法:
%Get()
-通过引用返回字符串消息作为第一个参数。%GetStream()
-给定初始化的文件字符流,此方法从队列中检索消息,并将其放入与该流关联的文件中。请注意,必须设置流的Filename
属性才能对其进行初始化。不支持二进制流。
- 检查调用的方法返回的值。请参阅“获取错误代码”。请记住,当队列为空时,IBM
WebSphere MQ
返回2033
。 - 检索完消息后,调用
Connection
对象的%Close()
方法以释放动态链接库的句柄。
示例1:ReceiveString()
下面的类方法从mqtest
队列检索消息。
///Method returns string or null or error message
ClassMethod ReceiveString() As %String
{
Set recv=##class(%Net.MQRecv).%New()
Set queue="mqtest"
Set qm="QM_antigua"
Set chan="S_antigua/TCP/antigua(1414)"
Set logfile="c:\mq-recv-log.txt"
Set check=recv.%Init(queue,qm,chan,logfile)
If 'check Quit recv.%GetLastError()
Set check=recv.%Get(.msg)
If 'check {
Set reasoncode=recv.%GetLastError()
If reasoncode=2033 Quit ""
Quit "ERROR: "_reasoncode
}
Quit msg
}
示例2:ReceiveCharacterStream()
以下方法可以检索更长的消息,因为它使用%GetStream()
:
/// Method returns reason code from IBM WebSphere MQ
ClassMethod ReceiveCharacterStream() As %Integer
{
Set recv=##class(%Net.MQRecv).%New()
Set queue="mqtest"
Set qm="QM_antigua"
Set chan="S_antigua/TCP/antigua(1414)"
Set logfile="c:\mq-recv-log.txt"
Set check=recv.%Init(queue,qm,chan,logfile)
If 'check Quit recv.%GetLastError()
//initialize the stream and tell it what file to use
//make sure filename is unique we can tell what we received
Set longmsg=##class(%FileCharacterStream).%New()
Set longmsg.Filename="c:\mq-received"_$h_".txt"
Set check=recv.%GetStream(longmsg)
If 'check Quit recv.%GetLastError()
Quit check
}
更新消息信息
%Net.MQSend
和%Net.MQRecv
类还提供以下方法:
%CorId()
(通过引用)更新上次读取的邮件的关联ID。
%ReplyQMgrName()
(通过引用)更新上次读取的消息的回复队列管理器名称。
%ReplyQName()
(通过引用)更新上次读取的消息的回复队列名称。
Troubleshooting
如果在使用IBM WebSphere MQ
的InterSystems IRIS接口时遇到问题,应该首先确定客户端是否安装正确并且可以与服务器通信。要执行这样的测试,可以使用IBM WebSphere MQ
提供的示例程序。可执行文件位于IBM WebSphere MQ
客户端的bin目录中。
以下步骤介绍如何在Windows
上使用这些示例程序。在其他操作系统上,细节可能会有所不同;请参考IBM文档并检查您的客户端中存在的文件的名称。
- 创建一个名为
MQSERVER
的环境变量。它的值的格式应该是channel_name/Transport/server
,其中channel_name
是要使用的通道的名称,Transport
是指示要使用的传输的字符串,而server
是服务器的名称。例如:S_Antigua/TCP/Antigua
- 在命令行中,输入以下命令:
amqsputc queue_name queue_manager_name
其中,QUEUE_NAME
是要使用的队列的名称,QUEUE_MANAGER_NAME
是队列管理器的名称。例如:
amqsputc mqtest QM_antigua
如果amqsputc
命令无法识别,请确保已更新PATH
环境变量以包括IBM WebSphere MQ
客户端的bin目录。
- 应该会看到几行代码,如下所示:
Sample AMQSPUT0 start
target queue is mqtest
- 现在可以发送消息了。只需键入每条消息,然后在每条消息后按Enter键即可。例如:
sample message 1
sample message 2
- 发送完邮件后,按两次Enter键。然后,将看到如下所示的行:
Sample AMQSPUT0 end
- 要完成此测试,我们将检索发送到队列的消息。在命令行中键入以下命令:
amqsgetc queue_name queue_manager_name
其中,QUEUE_NAME
是要使用的队列的名称,QUEUE_MANAGER_NAME
是队列管理器的名称。例如:
- 然后,应该看到一个起始行,后跟之前发送的消息,如下所示:
Sample AMQSGET0 start
message <sample message 1>
message <sample message 2>
- 此示例程序短暂等待接收任何其他消息,然后显示以下内容:
no more messages
Sample AMQSGET0 end
如果测试失败,请参考IBM文档。问题的可能原因包括以下几个方面:
- 安全问题
- 队列定义不正确
- 队列管理器未启动
边栏推荐
- 李迟2022年6月工作生活总结
- Scala basic tutorial -- 14 -- implicit conversion
- ESP32-C3入门教程 问题篇⑫——undefined reference to rom_temp_to_power, in function phy_get_romfunc_addr
- ITSS运维能力成熟度分级详解|一文搞清ITSS证书
- 学习路之PHP--phpstudy创建项目时“hosts文件不存在或被阻止打开”
- MySQL common add, delete, modify and query operations (crud)
- My colleagues quietly told me that flying Book notification can still play like this
- 被忽视的问题:测试环境配置管理
- Is it safe to open an account online? is that true?
- 6.26CF模拟赛B:数组缩减题解
猜你喜欢
Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
Li Kou brush question diary /day5/2022.6.27
2022年字节跳动日常实习面经(抖音)
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
1、 Introduction to C language
Mysql5.7 installation tutorial graphic explanation
ISO27001 certification process and 2022 subsidy policy summary
2022 ByteDance daily practice experience (Tiktok)
Angry bird design based on unity
[HCIA continuous update] WAN technology
随机推荐
爬虫(6) - 网页数据解析(2) | BeautifulSoup4在爬虫中的使用
MySQL常用增删改查操作(CRUD)
Scala basic tutorial -- 20 -- akka
ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
Scala基础教程--18--集合(二)
一直以为做报表只能用EXCEL和PPT,直到我看到了这套模板(附模板)
Li Kou brush question diary /day2/2022.6.24
如何使用 wget 和 curl 下载文件
Once the "king of color TV", he sold pork before delisting
What if the self incrementing ID of online MySQL is exhausted?
[go ~ 0 to 1] read, write and create files on the sixth day
Digital "new" operation and maintenance of energy industry
【系统盘转回U盘】记录系统盘转回U盘的操作
TorchDrug教程
机器学习概念漂移检测方法(Aporia)
基于unity的愤怒的小鸟设计
Detailed explanation of the maturity classification of ITSS operation and maintenance capability | one article clarifies the ITSS certificate
字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
基于C语言的菜鸟驿站管理系统
PB的扩展DLL开发(超级篇)(七)