当前位置:网站首页>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
边栏推荐
- Scala basic tutorial -- 15 -- recursion
- Load test practice of pingcode performance test
- Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
- 2022年字节跳动日常实习面经(抖音)
- Is it safe to open an account online? is that true?
- Li Kou brush question diary /day6/6.28
- 同事悄悄告诉我,飞书通知还能这样玩
- 其他InterSystems %Net工具
- 6.26CF模拟赛B:数组缩减题解
- 工厂从自动化到数字孪生,图扑能干什么?
猜你喜欢

奥迪AUDI EDI INVOIC发票报文详解

Scala基础教程--15--递归
![[go language question brushing chapter] go conclusion chapter | introduction to functions, structures, interfaces, and errors](/img/7a/16b481753d7d57f50dc8787eec8a1a.png)
[go language question brushing chapter] go conclusion chapter | introduction to functions, structures, interfaces, and errors

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

Scala basic tutorial -- 17 -- Collection

TorchDrug教程

Scala basic tutorial -- 20 -- akka

力扣刷题日记/day1/2022.6.23

ThreadLocal原理与使用

Lex and yacc based lexical analyzer + parser
随机推荐
[209] go language learning ideas
MySQL common add, delete, modify and query operations (crud)
2022 ByteDance daily practice experience (Tiktok)
Torchdrug tutorial
Scala basic tutorial -- 20 -- akka
My colleagues quietly told me that flying Book notification can still play like this
1、 Introduction to C language
MXNet对GoogLeNet的实现(并行连结网络)
奥迪AUDI EDI INVOIC发票报文详解
Lex and yacc based lexical analyzer + parser
Scala basic tutorial -- 15 -- recursion
能源行业的数字化“新”运维
模板_大整数减法_无论大小关系
How to open an account is safe,
IBM WebSphere MQ检索邮件
资料下载 丨首届腾讯技术开放日课程精华!
Thawte通配符SSL证书提供的类型有哪些
基于NCF的多模块协同实例
力扣刷题日记/day6/6.28
完善的js事件委托