当前位置:网站首页>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
边栏推荐
- [go ~ 0 to 1] read, write and create files on the sixth day
- Basic tutorial of scala -- 16 -- generics
- Machine learning concept drift detection method (Apria)
- 力扣刷题日记/day2/2022.6.24
- 物联网应用技术的就业前景和现状
- 字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验
- 激进技术派 vs 项目保守派的微服务架构之争
- Detailed explanation of the maturity classification of ITSS operation and maintenance capability | one article clarifies the ITSS certificate
- 6.26cf simulation race e: solution to the problem of price maximization
- How to improve development quality
猜你喜欢

Lex and yacc based lexical analyzer + parser

Torchdrug tutorial

Nature microbiology | viral genomes in six deep-sea sediments that can infect Archaea asgardii

Microservice architecture debate between radical technologists vs Project conservatives

TorchDrug教程

线上MySQL的自增id用尽怎么办?

Scala基础教程--13--函数进阶

Mxnet implementation of googlenet (parallel connection network)

正则替换【JS,正则表达式】

Basic tutorial of scala -- 16 -- generics
随机推荐
Scala basic tutorial -- 17 -- Collection
Scala基础教程--18--集合(二)
I always thought that excel and PPT could only be used for making statements until I saw this set of templates (attached)
ThreadLocal原理与使用
输入的查询SQL语句,是如何执行的?
[cloud native] what is the "grid" of service grid?
能源行业的数字化“新”运维
Journal des problèmes de brosse à boutons de force / day6 / 6.28
力扣刷题日记/day7/6.30
Caché WebSocket
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
C language printing exercise
How to improve development quality
模板_判断素数_开方 / 六素数法
[opencv introduction to mastery 9] opencv video capture, image and video conversion
Torchdrug tutorial
Li Kou brush question diary /day1/2022.6.23
How to open an account is safe,
6.26CF模拟赛B:数组缩减题解
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)