当前位置:网站首页>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.xOr later . To be specific :
- IBM
WebSphere MQThe client must be connected to InterSystems IRIS Installed on the same computer . Please note that , The installer will update as neededPATHEnvironment 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 MQThe 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.MQSendor%Net.MQRecvNew examples , It depends on whether you want to send or receive messages . - Connect to IBM
WebSphere MQThe 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 MQThe 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.MQSendor%Net.MQRecvTo 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
%InitMethod , 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
%ConnectMethod .
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
ConnectionThe 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
ConnectionObject'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 toConnectionObject 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
ConnectionThe 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 MQValid 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
ConnectionObject to specify the channel to use :
Connection- Appoint IBMWebSphere MQThe 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
ConnectionThe 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
ConnectionObject'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
ConnectionObject'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 toConnectionObject 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
MQThe 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 :
ApplIdentityDataSpecify the application identification message descriptor option .PutApplTypeAppointPUT Application TypeMessage 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.MQSendExample .ConnectionObject 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 setFilenameProperty 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
ConnectionObject'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,!边栏推荐
- Rookie post station management system based on C language
- Load test practice of pingcode performance test
- Scala基础教程--14--隐式转换
- MXNet对GoogLeNet的实现(并行连结网络)
- Digital "new" operation and maintenance of energy industry
- Li Kou brush question diary /day5/2022.6.27
- 正则替换【JS,正则表达式】
- How to improve development quality
- 奥迪AUDI EDI INVOIC发票报文详解
- Scala基础教程--12--读写数据
猜你喜欢

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

2022年字节跳动日常实习面经(抖音)

2022 ByteDance daily practice experience (Tiktok)

输入的查询SQL语句,是如何执行的?

Scala基础教程--16--泛型

力扣刷题日记/day6/6.28

激进技术派 vs 项目保守派的微服务架构之争

Machine learning concept drift detection method (Apria)

Basic tutorial of scala -- 16 -- generics

Uni app and uviewui realize the imitation of Xiaomi mall app (with source code)
随机推荐
完善的js事件委托
使用FTP
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation
Imitation of numpy 2
[opencv introduction to mastery 9] opencv video capture, image and video conversion
Lua EmmyLua 注解详解
Mxnet implementation of googlenet (parallel connection network)
Scala基础教程--16--泛型
2022 ByteDance daily practice experience (Tiktok)
Reptile elementary learning
uni-app与uviewUI实现仿小米商城app(附源码)
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
IBM WebSphere MQ检索邮件
Unity makes revolving door, sliding door, cabinet door drawer, click the effect of automatic door opening and closing, and automatically play the sound effect (with editor extension code)
力扣刷题日记/day8/7.1
Thawte通配符SSL证书提供的类型有哪些
Halcon模板匹配
[209] go language learning ideas
How is the entered query SQL statement executed?