当前位置:网站首页>Send and receive IBM WebSphere MQ messages
Send and receive IBM WebSphere MQ messages
2022-07-04 19:00:00 【User 7741497】
Send and receive IBM WebSphere MQ news
InterSystems IRIS by IBM WebSphere MQ
An interface is provided , You can use this interface in InterSystems IRIS and IBM WebSphere MQ
Exchange messages between message queues . To use this interface , Must be able to access IBM WebSphere MQ
The server , also IBM WebSphere MQ
The client must be connected to InterSystems IRIS Run on the same computer .
The interface is composed of %Net.MQSend
and %Net.MQRecv
Class composition , Both classes are %Net.abstractMQ
Subclasses of . These classes are used by InterSystems IRIS Dynamically linked libraries installed automatically on all appropriate platforms .( This is a Windows Upper MQInterface.dll
; Other platforms have different file extensions .). In turn, ,InterSystems IRIS Dynamic link library needs IBM WebSphere MQ
Dynamic link library .
This interface only supports sending and receiving text data , Binary data is not supported .
Use IBM WebSphere MQ Of RIS Interface
Usually , To use IBM WebSphere MQ
Of InterSystems IRIS Interface , Do the following :
- Ensure access
IBM WebSphereMQv7.x
Or later . To be specific :
- IBM
WebSphere MQ
The client must be connected to InterSystems IRIS Installed on the same computer . Please note that , The installer will update as neededPATH
Environment variables and add other system variables . - Make sure to restart the computer after installing the client , In order to InterSystems IRIS Be able to identify the client .
- The client must be able to access IBM
WebSphere MQ
The server . - The user name that will be used to access the server must have permission to use the queue manager and the queue that you plan to use .
- establish
%Net.MQSend
or%Net.MQRecv
New examples , It depends on whether you want to send or receive messages . - Connect to IBM
WebSphere MQ
The server . When doing this , You need to provide the following information :
- The name of the queue manager .
- The name of the queue to use .
- The channel that communicates with the queue . You can specify IBM
WebSphere MQ
The channel name of the server 、 Transmission mechanism and IP Address and port .
If in use IBM WebSphere MQ
Authentication function , You can also provide a name and password .
- call
%Net.MQSend
or%Net.MQRecv
To send or receive messages .
Be careful : To be in 64 position Linux On the platform IBM Websphere MQ
, You have to set LD_LIBRARY_PATH
To include MQ
Location of the library . Because it must be used for any MQ
Interface InterSystems IRIS Process setting path , So if the background process is running , You must start InterSystems IRIS Set this path before , And running IRIS Before the terminal at any UNIX Set this path in the terminal .
Get the error code
%Net.MQSend
and %Net.MQRecv
If the method of is successful, it returns 1, If not, return 0. In the event of a mistake , call %GetLastError()
Method , This method returns IBM WebSphere MQ
The last reason code given .
Create connection objects
You can go through IBM WebSphere MQ
Before sending or receiving messages , You have to create a Connection
object , This object can establish a connection to the queue manager 、 Open channels and queues for use . There are two ways to do this :
- have access to
%Init
Method , This method accepts parameters that specify all the required information . - You can use... After setting the attributes that specify all the required information for the first time
%Connect
Method .
Use %Init() Method
To use %Init()
Method to create a connection object , Do the following :
- establish
%Net.MQSend
( If you want to send a message ) or%Net.MQRecv
( If you want to receive messages ) Example . This topic refers to this instance as a connection object .
Be careful : If you receive <DYNAMIC LIBRARY LOAD>
error , It means that the dynamic link library is missing , also messages.log
file ( In the directory of system manager ) More details .
- If authentication is required , Please set up
Connection
The following properties of the object :
- user name - Specify the user name that is authorized to use this channel .
- password - Specify the password for the given user .
- call
Connection
Object's%Init()
Method . This method accepts the following parameters in sequence .
a. A string specifying the name of the queue ; This should be a valid queue for the specified queue manager .
b. Specify the string of the queue manager ; It should be IBM WebSphere MQ
Valid queue managers on the server .
If you omit this parameter , The system will use IBM WebSphere MQ
The default queue manager configured in . perhaps , If IBM WebSphere MQ
Configured as a queue manager determined by the queue name , Then the system will use a queue manager suitable for the given queue name .
c. Specify the string of the channel specification , The format is as follows :
"channel_name/transport/host_name(port)"
here ,channel_name
Is the name of the channel to be used ,Transport
Is the transmission used by the channel ,host_name
Is to run IBM WebSphere MQ
Server name of the server ( or IP Address ),port
Is the port that this channel should use .
The transmission can be one of the following :TCP
、LU62
、NETBIOS
、SPX
for example :
"CHAN_1/TCP/rodan(1401)"
"CHAN_1/TCP/127.0.0.1(1401)"
If you omit this parameter , The system will use IBM WebSphere MQ
The default channel specification configured in . perhaps , If the system has been configured so that the channel is determined by the queue name , Then the system uses the channel suitable for the given queue name .
d. An optional string , It specifies the log file to write error messages to . By default , No logging .
- Check
%Init()
The value returned by the . If the method returns 1, It indicates that the connection has been successfully established , have access toConnection
Object to send or receive messages ( It depends on the class used ).
Use %Connect() Method
In some cases , You may prefer to specify all the details of the connection separately . So , Please use %Connect()
Method , As shown below :
- establish
%Net.MQSend
( If you want to send a message ) or%Net.MQRecv
( If you want to receive messages ) Example . As mentioned earlier , This topic refers to this instance as a connection object .
Be careful : If you receive <DYNAMIC LIBRARY LOAD>
error , It means that the dynamic link library is missing , also messages.log
file ( In the directory of system manager ) More details .
- Set up
Connection
The following properties of the object :
QName
-( Mandatory ) Specify the queue name ; This should be a valid queue for the specified queue manager .QMgr
- Specify the queue manager to use ; It should be IBMWebSphere MQ
Valid queue managers on the server .
If you omit this parameter , The system will use IBM WebSphere MQ
The default queue manager configured in . perhaps , If IBM WebSphere MQ
Configured as a queue manager determined by the queue name , Then the system will use a queue manager suitable for the given queue name .
- perhaps , By setting
Connection
Object to specify the channel to use :
Connection
- Appoint IBMWebSphere MQ
The host and port of the server . for example :"127.0.0.1:1401"
.Channel
- Specify the name of the channel to use . This has to be IBM WebSphere MQ A valid channel on the server .Transport
- Specify the transport used by the channel . This attribute can be one of the following :"TCP"
,"LU62"
,"NETBIOS"
,"SPX"
If these parameters are omitted , The system will use IBM WebSphere MQ
The default channel specification configured in . perhaps , If the system has been configured so that the channel is determined by the queue name , Then the system uses the channel suitable for the given queue name .
- If the channel requires authentication , Please set up
Connection
The following properties of the object :
- user name - Specify the user name that is authorized to use this channel .
- password - Specify the password for the given user .
- call
Connection
Object's%ErrLog()
Method . This method accepts a parameter , That is, the name of the log file to be used for this connection object . - Check
%ErrLog()
The value returned by the . - call
Connection
Object's%Connect()
Method . - Check
%Connect()
The value returned by the . If the method returns 1, It indicates that the connection has been successfully established , have access toConnection
Object to send or receive messages ( It depends on the class you use ).
Specify character set (CCSID)
To set the character set for message conversion , Please call Connection
Object's %SetCharSet()
Method . Specified in the IBM WebSphere MQ
Integer encoded character set used in ID(CCSID)
.
- If you are sending a message , This should be the character set of these messages . If the character set is not specified , be MQ The system assumes that the message is used
MQ
The default character set specified by the client . - If you want to retrieve messages , Then this is the character set to translate these messages .
To get the currently used CCSID
, Please call %charset()
Method . This method returns by reference CCSID
, And back to 1 or 0 To indicate whether it was successful .
Specify other message options
To specify message descriptor options , You can choose to set the following properties of the connection object :
ApplIdentityData
Specify the application identification message descriptor option .PutApplType
AppointPUT Application Type
Message descriptor options .
Send a message
To send an email , Do the following :
- according to “ Create connection objects ” Create a connection object as described in . under these circumstances , Please create
%Net.MQSend
Example .Connection
Object has a message queue , Messages can be sent to this queue . - Call the following methods as needed :
%put()
- Given a string , This method writes the string to the message queue .%PutStream()
- Given the initialized file character stream , This method writes the string to the message queue . Please note that , The... Of the stream must be setFilename
Property to initialize it . Binary streams are not supported .%SetMsgId()
- Given a string , This method uses this string as the message of the next message sent ID.
- Check the value returned by the called method .
- After retrieving the message , call
Connection
Object's%Close()
Method to release the handle of the dynamic link library .
Example 1:SendString()
The following class methods use queue managers QM_antigua
And called S_antigua
Queue channel to queue mqtest
Send a simple string message . Channel use TCP transmission ,IBM WebSphere MQ
The server is running under the name Antigua
On the machine , And listen on the port 1401.
///Method returns reason code from IBM WebSphere MQ
ClassMethod SendString() As %Integer
{
Set send=##class(%Net.MQSend).%New()
Set queue="mqtest"
Set qm="QM_antigua"
Set chan="S_antigua/TCP/antigua(1414)"
Set logfile="c:\mq-send-log.txt"
Set check=send.%Init(queue,qm,chan,logfile)
If 'check Quit send.%GetLastError()
//send a unique message
Set check=send.%Put("This is a test message "_$h)
If 'check Quit send.%GetLastError()
Quit check
}
Example 2:SendCharacterStream()
The following class method sends the contents of the file character stream . It uses the same queue as in the previous example :
///Method returns reason code from IBM WebSphere MQ
ClassMethod SendCharacterStream() As %Integer
{
Set send=##class(%Net.MQSend).%New()
Set queue="mqtest"
Set qm="QM_antigua"
Set chan="S_antigua/TCP/antigua(1414)"
Set logfile="c:\mq-send-log.txt"
Set check=send.%Init(queue,qm,chan,logfile)
If 'check Quit send.%GetLastError()
//initialize the stream and tell it what file to use
Set longmsg=##class(%FileCharacterStream).%New()
Set longmsg.Filename="c:\input-sample.txt"
Set check=send.%PutStream(longmsg)
If 'check Quit send.%GetLastError()
Quit check
}
Example 3: Send a message from the terminal
The following example shows how to IBM WebSphere MQ
Queue terminal sessions that send messages . This can only be configured IBM WebSphere MQ
Run on the client's computer .
Set MySendQ = ##class(%Net.MQSend).%New()
Do MySendQ.%Init("Q_1", "QM_1","QC_1/TCP/127.0.0.1(1401)","C:\mq.log")
Do MySendQ.%Put("Hello from tester")
Set MyRecvQ =##class(%Net.MQRecv).%New()
Do MyRecvQ.%Init("Q_1", "QM_1","QC_1","C:\mq.log")
Do MyRecvQ.%Get(.msg, 10000)
Write msg,!
边栏推荐
- What types of Thawte wildcard SSL certificates provide
- I wrote a learning and practice tutorial for beginners!
- [cloud native] what is the "grid" of service grid?
- Uni app and uviewui realize the imitation of Xiaomi mall app (with source code)
- repeat_P1002 [NOIP2002 普及组] 过河卒_dp
- 力扣刷题日记/day6/6.28
- VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
- 【2022年江西省研究生数学建模】冰壶运动 思路分析及代码实现
- Lua emmylua annotation details
- Wanghongru research group of Institute of genomics, Chinese Academy of Agricultural Sciences is cordially invited to join
猜你喜欢
TorchDrug教程
Scala基础教程--18--集合(二)
Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg
力扣刷题日记/day3/2022.6.25
[go ~ 0 to 1] read, write and create files on the sixth day
1、 Introduction to C language
一、C语言入门基础
基于unity的愤怒的小鸟设计
Scala基础教程--17--集合
基于NCF的多模块协同实例
随机推荐
Angry bird design based on unity
Load test practice of pingcode performance test
[go ~ 0 to 1] read, write and create files on the sixth day
Lex and yacc based lexical analyzer + parser
MXNet对GoogLeNet的实现(并行连结网络)
基于lex和yacc的词法分析器+语法分析器
力扣刷题日记/day6/6.28
6.26CF模拟赛B:数组缩减题解
【2022年江西省研究生数学建模】冰壶运动 思路分析及代码实现
Torchdrug tutorial
Li Kou brush question diary /day5/2022.6.27
Li Kou brush question diary /day4/6.26
Scala basic tutorial -- 14 -- implicit conversion
Interpretation of SIGMOD '22 hiengine paper
How is the entered query SQL statement executed?
力扣刷题日记/day7/2022.6.29
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation
Scala basic tutorial -- 13 -- advanced function
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年字节跳动日常实习面经(抖音)