Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set the Msg Id in VB while putting Message in IBM MQ.

Status
Not open for further replies.

satish279

Programmer
Jul 17, 2005
3
GB
Hi All,

I am trying to write a program in VB where i have to set the message id in vb program before putting the message in IBM MQ.

Can someone help me to get the sample program in VB where i can get the information like how to set the message id. Do we need to convert the Msg id into binary mode. If yes then how can we do that? When i am trying to assign some alphnumeric value it is failing and throwing reason code= 6111 and reason name: MQRC_BINARY_DATA_LENGTH_ERROR

Thanks in advance..
 
There are quite a few examples of VB interacting with the MQ environment on this site... Just did a quick search a few mins ago and found a ton of articles on it.

What exactly are you trying to do?

Also, check out this quick VB script I put together as a demo for use of folks on this site:



ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise
 
Hi Wholsea,

Thanks for providing the code of VB interactive with MQ. But in my case i have to put messaged with the transaction id generated in my application as a message id in MQ. And the length of transaction id is 32 char (D2C163FD2B344BD3A6A3A893E86209F1). But as far as my knowledge Message id length is 24 byte. Is there any way where we can push this transaction id in MQ. And do i need to convert this trans id into hexa or any binary formate before putting the message. If yes then do you have any code to convert this?

Thanks in advance
Regards...
 
Assuming transaction ID always contains hex digits, then you can convert every two hex digits to a binary value that occupies 1 byte. The entire 32 digits can then be passed in 16 bytes of the message-id. MQ won't touch the value in message-id, so at the other end or when the message makes it's return trip, the translation may need to be reversed.

Here's a couple of VB functions that do the translation:

Public Function Hex2BinString(hexstring)
'compress hex to binary
Dim i As Integer
Dim txOut As String
For i = Len(hexstring) To 1 Step -2
txOut = Chr(Eval(CByte("&H" + Mid$("0" + hexstring, i, 1) + Mid$(hexstring, i, 1)))) + txOut
Next
Hex2BinString = txOut
Exit Function
End Function

Public Function Bin2HexString(binstring)
'expand binary string to hex
Dim i As Integer
Dim txOut As String
For i = 1 To Len(binstring)
txOut = txOut + Hex(Asc(Mid$(binstring, i, 1)))
Next
Bin2HexString = txOut
Exit Function
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top