当前位置:网站首页>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.MQRecv
Example .Connection
Object 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 setFilename
Property 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 MQ
return2033
. - After retrieving the message , call
Connection
Object'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
MQSERVER
Environment variables of . The format of its value should bechannel_name/Transport/server
, amongchannel_name
Is the name of the channel to be used ,Transport
Is a string indicating the transfer to be used , andserver
Is 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 end
If 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
边栏推荐
- .NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
- Scala basic tutorial -- 13 -- advanced function
- Li Chi's work and life summary in June 2022
- Scala基础教程--12--读写数据
- LD_ LIBRARY_ Path environment variable setting
- Wireshark packet capturing TLS protocol bar displays version inconsistency
- 基于unity的愤怒的小鸟设计
- [opencv introduction to mastery 9] opencv video capture, image and video conversion
- Li Kou brush question diary /day4/6.26
- TCP waves twice, have you seen it? What about four handshakes?
猜你喜欢
Deleting nodes in binary search tree
力扣刷题日记/day2/2022.6.24
Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
删除二叉搜索树中的节点附图详解
Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
线上MySQL的自增id用尽怎么办?
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
Microservice architecture debate between radical technologists vs Project conservatives
Mysql5.7 installation tutorial graphic explanation
随机推荐
Rookie post station management system based on C language
Caché JSON 使用JSON适配器
Scala basic tutorial -- 13 -- advanced function
激进技术派 vs 项目保守派的微服务架构之争
repeat_P1002 [NOIP2002 普及组] 过河卒_dp
. Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
How to modify icons in VBS or VBE
力扣刷题日记/day3/2022.6.25
Mysql5.7 installation tutorial graphic explanation
发送和接收IBM WebSphere MQ消息
6.26CF模拟赛E:价格最大化题解
一、C语言入门基础
基于lex和yacc的词法分析器+语法分析器
Scala基础教程--15--递归
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
Caché WebSocket
C language printing exercise
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
谷粒商城(一)