当前位置:网站首页>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,!边栏推荐
- [system disk back to U disk] record the operation of system disk back to U disk
- Li Kou brush question diary /day1/2022.6.23
- LD_ LIBRARY_ Path environment variable setting
- 资料下载 丨首届腾讯技术开放日课程精华!
- I always thought that excel and PPT could only be used for making statements until I saw this set of templates (attached)
- 6.26cf simulation race e: solution to the problem of price maximization
- 6.26CF模拟赛E:价格最大化题解
- Scala基础教程--16--泛型
- Caché JSON 使用JSON适配器
- Angry bird design based on unity
猜你喜欢

Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组

TorchDrug教程

1、 Introduction to C language

How to modify icons in VBS or VBE

Li Kou brush question diary /day8/7.1
![[go ~ 0 to 1] read, write and create files on the sixth day](/img/cb/b6785ad7d7c7df786f718892a0c058.png)
[go ~ 0 to 1] read, write and create files on the sixth day

Microservice architecture debate between radical technologists vs Project conservatives

Neglected problem: test environment configuration management

Rookie post station management system based on C language

Uni app and uviewui realize the imitation of Xiaomi mall app (with source code)
随机推荐
如何提高开发质量
Li Kou brush question diary /day8/7.1
奥迪AUDI EDI INVOIC发票报文详解
Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
[HCIA continuous update] network management and operation and maintenance
Scala basic tutorial -- 14 -- implicit conversion
发送和接收IBM WebSphere MQ消息
Microservice architecture debate between radical technologists vs Project conservatives
[209] go language learning ideas
Blue bridge: sympodial plant
Lua emmylua annotation details
Basic tutorial of scala -- 16 -- generics
Scala基础教程--13--函数进阶
使用FTP
正则替换【JS,正则表达式】
Machine learning concept drift detection method (Apria)
1、 Introduction to C language
Torchdrug tutorial
Li Chi's work and life summary in June 2022
一、C语言入门基础