当前位置:网站首页>IBM WebSphere MQ retrieving messages
IBM WebSphere MQ retrieving messages
2022-07-04 19:00:00 【User 7741497】
IBM WebSphere MQ Retrieve messages
Retrieve messages
To retrieve messages , Do the following :
- according to “ Create connection objects ” Create a connection object as described in . under these circumstances , Please create
%Net.MQRecvExample .ConnectionObject has a message queue , You can retrieve messages from . - Call the following methods as needed :
%Get()- Return a string message by reference as the first parameter .%GetStream()- Given the initialized file character stream , This method retrieves messages from the queue , And put it into the file associated with the stream . Please note that , The... Of the stream must be setFilenameProperty to initialize it . Binary streams are not supported .
- Check the value returned by the called method . see also “ Get the error code ”. please remember , When the queue is empty ,IBM
WebSphere MQreturn2033. - After retrieving the message , call
ConnectionObject's%Close()Method to release the handle of the dynamic link library .
Example 1:ReceiveString()
The following class methods are from mqtest Queue retrieval messages .
///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
} Example 2:ReceiveCharacterStream()
The following methods can retrieve longer messages , Because it uses %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
}Update message information
%Net.MQSend and %Net.MQRecv Class also provides the following methods :
%CorId()
( By quoting ) Update the association of the last read message ID.
%ReplyQMgrName()
( By quoting ) Update the reply queue manager name of the last read message .
%ReplyQName()
( By quoting ) Update the reply queue name of the last read message .
Troubleshooting
If you are using IBM WebSphere MQ Of InterSystems IRIS Interface encountered a problem , You should first determine whether the client is installed correctly and can communicate with the server . To perform such a test , have access to IBM WebSphere MQ Sample program provided . The executable is located at IBM WebSphere MQ Client's bin Directory .
The following steps describe how to Windows Use these sample programs on . On other operating systems , The details may vary ; Please refer to IBM Document and check the name of the file that exists in your client .
- Create a file called
MQSERVEREnvironment variables of . The format of its value should bechannel_name/Transport/server, amongchannel_nameIs the name of the channel to be used ,TransportIs a string indicating the transfer to be used , andserverIs the name of the server . for example :S_Antigua/TCP/Antigua - On the command line , Enter the following command :
amqsputc queue_name queue_manager_name among ,QUEUE_NAME Is the name of the queue to be used ,QUEUE_MANAGER_NAME Is the name of the queue manager . for example :
amqsputc mqtest QM_antigua If amqsputc The command does not recognize , Please make sure it is updated PATH Environment variables to include IBM WebSphere MQ Client's bin Catalog .
- You should see a few lines of code , As shown below :
Sample AMQSPUT0 start
target queue is mqtest- Now you can send messages . Just type in each message , Then press... After each message Enter Press the key . for example :
sample message 1
sample message 2- After sending the email , Press two times. Enter key . then , You will see the line shown below :
Sample AMQSPUT0 end- To complete this test , We will retrieve the messages sent to the queue . Type the following command on the command line :
amqsgetc queue_name queue_manager_name among ,QUEUE_NAME Is the name of the queue to be used ,QUEUE_MANAGER_NAME Is the name of the queue manager . for example :
- then , You should see a starting line , Followed by the message sent before , As shown below :
Sample AMQSGET0 start
message <sample message 1>
message <sample message 2>- This sample program briefly waits to receive any other messages , Then display the following :
no more messages
Sample AMQSGET0 endIf the test fails , Please refer to IBM file . The possible causes of the problem include the following aspects :
- safety problem
- The queue definition is incorrect
- The queue manager did not start
边栏推荐
- 物联网应用技术的就业前景和现状
- Lua emmylua annotation details
- 【机器学习的数学基础】(一)线性代数(Linear Algebra)(上+)
- Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
- 6.26CF模拟赛B:数组缩减题解
- [cloud voice suggestion collection] cloud store renewal and upgrading: provide effective suggestions, win a large number of code beans, Huawei AI speaker 2!
- 谷粒商城(一)
- Perfect JS event delegation
- 资料下载 丨首届腾讯技术开放日课程精华!
- 力扣刷题日记/day7/6.30
猜你喜欢

一种将Tree-LSTM的强化学习用于连接顺序选择的方法

提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像

奥迪AUDI EDI INVOIC发票报文详解

物联网应用技术的就业前景和现状

Li Kou brush question diary /day8/7.1

Li Kou brush question diary /day3/2022.6.25

中国农科院基因组所汪鸿儒课题组诚邀加入

力扣刷题日记/day1/2022.6.23

Rookie post station management system based on C language

Digital "new" operation and maintenance of energy industry
随机推荐
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
Neglected problem: test environment configuration management
发送和接收IBM WebSphere MQ消息
【2022年江西省研究生数学建模】冰壶运动 思路分析及代码实现
力扣刷題日記/day6/6.28
同事悄悄告诉我,飞书通知还能这样玩
Li Kou brush question diary /day2/2022.6.24
[system disk back to U disk] record the operation of system disk back to U disk
力扣刷题日记/day3/2022.6.25
ESP32-C3入门教程 问题篇⑫——undefined reference to rom_temp_to_power, in function phy_get_romfunc_addr
提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像
技术分享 | 接口测试价值与体系
Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
[cloud voice suggestion collection] cloud store renewal and upgrading: provide effective suggestions, win a large number of code beans, Huawei AI speaker 2!
Li Kou brush question diary /day5/2022.6.27
6.26cf simulation match B: solution to array reduction problem
未来几年中,软件测试的几大趋势是什么?
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
6.26CF模拟赛E:价格最大化题解
Detailed explanation of the maturity classification of ITSS operation and maintenance capability | one article clarifies the ITSS certificate