ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Version 2 header when getting message in .Net MA7P

Post new topic  Reply to topic
 Version 2 header when getting message in .Net MA7P « View previous topic :: View next topic » 
Author Message
Steve Martin
PostPosted: Mon Dec 08, 2003 3:22 pm    Post subject: Version 2 header when getting message in .Net MA7P Reply with quote

Novice

Joined: 01 Aug 2003
Posts: 13

I am using the MA7P .Net library to connect to a remote queue on Solaris. Both the client and the server are running 5.3 CSD4. On the other end, I have a WebSphere java program connecting via a server binding connection. (It seems to behave the same if it is a client connection via a channel as well).

When I put a message into the Queue from .Net the server receives it and the message body has a lot of garbage characters before and after it. When it sends the message back the same thing happens.

I also see these characters if I pull the messages off using the ActiveX component called from the same .Net application.

When I send messages from the ActiveX component to the WebSphere appliction, these garbage characters do not show up.

It seems like it could be an encoding issue but I tried setting them the same on the two servers.

The code for getting the message using the MA7P library looks like this:

Code:

    Dim msg As MQMessage = New MQMessage
    Dim opts As MQGetMessageOptions = getGetOptions(pWait)

    Try
      msg.CorrelationId = pRequestMessage.MessageId
      opts.MatchOptions = MQC.MQMO_MATCH_CORREL_ID
      vQueue.Get(msg, opts)
      vPendingOperation = True
    Catch ex As Exception When (InStr(ex.Message, CStr(MQC.MQRC_NO_MSG_AVAILABLE), CompareMethod.Text) <> 0)
      msg = Nothing
    End Try


The code for sending the message using MA7P looks like this.

Code:

Dim msgReply As MQMessage = New MQMessage

' Convert the string into a byte[].
Dim utf8Bytes As Byte() = Encoding.Unicode.GetBytes(reply)
msgReply.Persistence = IBM.WMQ.MQC.MQPER_NOT_PERSISTENT
msgReply.Format = MQC.MQFMT_NONE
msgReply.WriteString(reply)
msgReply.CorrelationId = msgRequest.MessageId

Dim expiry As TimeSpan = New TimeSpan(msgRequest.Expiry * 100 * TimeSpan.TicksPerMillisecond)

Dim opts As MQPutMessageOptions
opts = getPutOptions()

msgReply.Expiry = CInt(pExpiry.TotalMilliseconds / 100)

vQueue.Put(msgReply, opts)


The code for pulling the message from the ActiveX component looks like:

Code:
   
QManager.Name = cboInQM.Text
   QManager.Connect
   
   Set Queue = QManager.AccessQueue(cboInQueue.Text, MQOO_INPUT_SHARED Or MQOO_FAIL_IF_QUIESCING)
   Queue.Open
   
   Set GetMessageOptions = MQSess.AccessGetMessageOptions()
   GetMessageOptions.Options = GetMessageOptions.Options Or MQGMO_NO_SYNCPOINT
   
   Dim Msg As MQMessage
   Set Msg = MQSess.AccessMessage
   
   Msg.CorrelationId = Me.txtMessageId.Text
   
   On Error Resume Next
   Call Queue.Get(Msg, GetMessageOptions)


The code for putting the message from the ActiveX component looks like:
Code:
   
   QManager.Name = cboOutQM.Text
   QManager.Connect
   
   Set Queue = QManager.AccessQueue(cboOutQueue.Text, MQOO_OUTPUT Or MQOO_FAIL_IF_QUIESCING)
   Queue.Open
   
   Set PutMessageOptions = MQSess.AccessPutMessageOptions
   PutMessageOptions.Options = PutMessageOptions.Options Or MQPMO_NO_SYNCPOINT
   
   Dim i As Integer
   Dim payload As String
   payload = txtOutPayload.Text
   
   Dim Msg As MQMessage
   Set Msg = MQSess.AccessMessage
   Msg.MessageData = payload

   Msg.CorrelationId = Me.txtMessageId.Text
   
   On Error GoTo 0
   Queue.Put Msg
   On Error Resume Next
 
   Queue.Close
   QManager.Disconnect


Any insight to this problem would be appreciated.


Last edited by Steve Martin on Wed Dec 10, 2003 2:22 pm; edited 1 time in total
Back to top
View user's profile Send private message
mrlinux
PostPosted: Wed Dec 10, 2003 10:34 am    Post subject: Reply with quote

Grand Master

Joined: 14 Feb 2002
Posts: 1261
Location: Detroit,MI USA

You might want to try add the option to convert on your MQGET request.
_________________
Jeff

IBM Certified Developer MQSeries
IBM Certified Specialist MQSeries
IBM Certified Solutions Expert MQSeries
Back to top
View user's profile Send private message Send e-mail
Steve Martin
PostPosted: Wed Dec 10, 2003 11:14 am    Post subject: Thanks for the idea Reply with quote

Novice

Joined: 01 Aug 2003
Posts: 13

I have added the following line to getting messages:

Code:
Dim opts As MQGetMessageOptions = New MQGetMessageOptions

opts.Options = IBM.WMQ.MQC.MQGMO_WAIT

opts.Options = opts.Options Or IBM.WMQ.MQC.MQGMO_FAIL_IF_QUIESCING
opts.Options = opts.Options Or IBM.WMQ.MQC.MQGMO_CONVERT


The bytes leading the message data look like "MDE " and then some "garbage" characters start. The first looks like a 0 byte.
The actual data starts at byte 72.

When I pull the data for the next message, it appears that the buffer is not cleared out or shortened because I see leftovers of the previous longer messages.

The code I am using to pull the message data is as follows:

Code:
    Dim rawRequest As String = pMessage.ReadString(dataLength)
    Dim startDelimPos As Int32 = UCase(rawRequest).IndexOf(BEGIN_DELIM)
    Dim endDelimPos As Int32 = UCase(rawRequest).LastIndexOf(END_DELIM)

    Dim request As String
    If startDelimPos <> -1 And endDelimPos <> -1 Then
      Dim dataStart As Int32 = startDelimPos + Len(BEGIN_DELIM)
      Dim dataEnd As Int32 = endDelimPos - 1
      Dim dataLen As Int32 = dataEnd - dataStart + 1
      request = rawRequest.Substring(dataStart, dataLen)
    Else
      request = rawRequest
    End If


To work around this problem, I have prefixed and and suffixed the data being sent with some delimiters. and part of the code deals with stripping this out.
Back to top
View user's profile Send private message
JasonE
PostPosted: Wed Dec 10, 2003 2:46 pm    Post subject: Reply with quote

Grand Master

Joined: 03 Nov 2003
Posts: 1220
Location: Hursley

Have you tried using the .net code which shipped in csd05 - it does include fixes beyond what was shipped as the (unsupported) cat 2 version. You'll need to rebuild your app to link against the newer library as well.

If it still fails, let me know - I might be able to look at a trace of both sides for you if I get some spare time to see what is going on
Back to top
View user's profile Send private message
Steve Martin
PostPosted: Thu Dec 11, 2003 7:54 am    Post subject: How get CSD5 for client libraries only Reply with quote

Novice

Joined: 01 Aug 2003
Posts: 13

I have installed MQ Client CSD04. Can I get CSD05 for the client. I would prefer not to install the server portion since that will not be used and would prefer to have less installed on an Internet facing server.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Dec 11, 2003 8:01 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You can run CSD05 for server on the client. It will only update the things it needs to.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Steve Martin
PostPosted: Thu Dec 11, 2003 1:09 pm    Post subject: Situation is "resolved" Reply with quote

Novice

Joined: 01 Aug 2003
Posts: 13

I have modified things so that I can accommodate the version 2 headers (required CSD05 to make message.version read/write) and so am not having to skip the "garbage characters at the beginning. In addition, there appeared to be a problem with character sets and CONVERT helped that.

I still am not sure why I am getting Version 2 headers and will continue research.

Thanks everyone for your help!

Steve Martin
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Version 2 header when getting message in .Net MA7P
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.