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 » General IBM MQ Support » MQPUT/MQGET

Post new topic  Reply to topic Goto page 1, 2  Next
 MQPUT/MQGET « View previous topic :: View next topic » 
Author Message
hunterKillerz
PostPosted: Fri Jun 18, 2010 11:26 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

And i was working on file transfer (.jpg), I have convert the .jpg file to byte array and send the byte array to queue.

Is it possible to retrieve the message as byte array, instead of in string format? bcoz the output for default MQGET is in String format. ( I've tried MQGETX and MQGETANY, tried out MQBYTE, it just doesn't work)

Code:

Sub MQGET _
 (ByVal Hconn As Long, _
  ByVal Hobj As Long, _
  MsgDesc As MQMD, _
  GetMsgOpts As MQGMO, _
  ByVal BufferLength As Long, _
  Buffer As String, _
  DataLength As Long, _
  CompCode As Long, _
  Reason As Long)




I was hoping to get back the byte array and write it to .jpg file again.(VB6.0)
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Jun 19, 2010 4:44 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

What is the content of your MQMD.FORMAT field on the PUT?
This may well drive what you get back on the GET....

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
hunterKillerz
PostPosted: Sat Jun 19, 2010 6:27 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

fjb_saper wrote:
What is the content of your MQMD.FORMAT field on the PUT?
This may well drive what you get back on the GET....

Have fun





the MQMD.FORMAT = NONE =)
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Jun 19, 2010 7:14 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

hunterKillerz wrote:
fjb_saper wrote:
What is the content of your MQMD.FORMAT field on the PUT?
This may well drive what you get back on the GET....

Have fun





the MQMD.FORMAT = NONE =)

Well with this you should not have any conversion. So what you get is what the other guy put... think byte[] and BytesMessage.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
hunterKillerz
PostPosted: Sun Jun 20, 2010 7:17 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

Quote:

Well with this you should not have any conversion. So what you get is what the other guy put... think byte[] and BytesMessage.

Have fun




Yea but the output of MQGET is in String format, how can i change it to Byte[] ?

I've tried to use a function to convert string--> Byte with
Code:

strconv(message,vbfromunicode)


but doesn't work. coz the converted byte array fails to write back to jpg.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jun 21, 2010 4:54 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

hunterKillerz wrote:
Yea but the output of MQGET is in String format, how can i change it to Byte[] ?


No it isn't. The "output" of MQGet (even in VB6) is a memory buffer. If your code is treating it as string that's a code issue. Once you've PUT the message with a Format of NONE in the MQMD then WMQ loses all interest in the contents of the message.

Make sure the MQMD is set as you expect (i.e. NONE) and review your code.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Mon Jun 21, 2010 1:03 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Vitor wrote:
hunterKillerz wrote:
Yea but the output of MQGET is in String format, how can i change it to Byte[]?

No it isn't.

If MQMD.Format = MQFMT_NONE, then the "String format" is not coming from MQ.

What does the input to MQPUT look like? A byte[] or a String?

If the data provided to MQPUT is wrong, then tweaking the MQGET options won't help.
Back to top
View user's profile Send private message
hunterKillerz
PostPosted: Mon Jun 21, 2010 5:55 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

thx for the replies,bro.
its ok i will put my code here. (VB6.0)

This is where i MQPUT a jpeg file
Code:


Private Sub putQ()

  Dim md As MQMD            ' Message descriptor
  Dim pmo As MQPMO          ' MQPUT message options
  Dim CompCode As Long      ' Completion code
  Dim Reason As Long        ' Reason code


            MQMD_DEFAULTS md
            md.Format = MQFMT_NONE
            MQPMO_DEFAULTS pmo

            MQPUT gHcon, gHobj, md, pmo, filelen("C:\myPic.jpg)", _
            FileToByteArray("C:\myPic.jpg"), CompCode, Reason
           
End Sub



This is my FileToByteArray function
Code:


Function FileToByteArray(ByVal fName As String) As Variant

    Dim b() As Byte
    Dim n As Long
   
    n = FileLen(fName)
    ReDim b(n - 1)
   
    Open fName For Binary Access Read As #1
    Get #1, , b()
    Close #1
   
    FileToByteArray = b
   
End Function



This is where i MQGET:
Code:

Private Sub getQ()
  Dim md As MQMD          'message desciptor
  Dim gmo As MQGMO        'get message options
  Dim buflen As Long      'length of get buffer
  Dim Buffer As String * CCHBUFFER   'got message
  Dim messlen As Long     'length of returned message
  Dim CompCode As Long    'completion code
  Dim Reason As Long      'reason code

        MQMD_DEFAULTS md
        md.Format = MQMO_NONE
        MQGMO_DEFAULTS gmo
        gmo.Options = MQGMO_NO_WAIT
 
        buflen = CCHBUFFER
     
       
        MQGET gHconG, gHobjG, md, gmo, CCHBUFFER , Buffer, messlen, _
        CompCode, Reason

        If CompCode <> MQCC_FAILED Then
         
             ' I was hoping to reform back the jpeg here.
       
       End If
End Sub

Back to top
View user's profile Send private message
hunterKillerz
PostPosted: Mon Jun 21, 2010 6:05 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

Vitor wrote:


No it isn't. The "output" of MQGet (even in VB6) is a memory buffer. If your code is treating it as string that's a code issue. Once you've PUT the message with a Format of NONE in the MQMD then WMQ loses all interest in the contents of the message.

Make sure the MQMD is set as you expect (i.e. NONE) and review your code.



Ok, but what i see from the MQPUT structure is, the parameter of Buffer is a String instead of Any/or other format. that's the problem.

And then, MQGET part, the ouput parameter is in String type as well, its the syntax of MQGET/MQPUT in VB6.0,seems to be restricted unlike in java. (Correct me if I'm wrong) =)
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jun 21, 2010 6:44 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

hunterKillerz wrote:
its the syntax of MQGET/MQPUT in VB6.0,seems to be restricted unlike in java. (Correct me if I'm wrong) =)


Have you tried not using String? I accept that's what the example in the manual gives but does it work? With a little ingenuity in the code?

Other options include using Base64 encoding, or coming to terms with the fact that VB6 is obsolete and switch to VB.NET. This gives you access to a different range of interfaces that IMHO are better suited to what you're attempting.

(The VB6 interface isn't all that great which is why XMS was released back then)
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jun 21, 2010 7:38 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

on the Get try using
Dim Buffer as byte[] * CCHBUFFER

and not dim Buffer as String!!!
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Mon Jun 21, 2010 7:48 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

fjb_saper wrote:
on the Get try using
Dim Buffer as byte[] * CCHBUFFER

and not dim Buffer as String!!!


OK, we replace ingenuity with fish...
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
SAFraser
PostPosted: Tue Jun 22, 2010 7:54 am    Post subject: Reply with quote

Shaman

Joined: 22 Oct 2003
Posts: 742
Location: Austin, Texas, USA

I wish he had started a different thread for the file transfer questions...

On the connection question: What am I missing here? It appears he has an app running on an MQ server and he is putting into a remote queue (serviced, of course, by a sender/receiver pair). Why are we giving him advice about limiting channel connections? It doesn't matter if he has 1 or 200 or 500 applications putting and getting, he is still using a single channel.

Enlighten me, O Wise Ones.
Back to top
View user's profile Send private message
exerk
PostPosted: Tue Jun 22, 2010 8:07 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

SAFraser wrote:
I wish he had started a different thread for the file transfer questions...

On the connection question: What am I missing here? It appears he has an app running on an MQ server and he is putting into a remote queue (serviced, of course, by a sender/receiver pair). Why are we giving him advice about limiting channel connections? It doesn't matter if he has 1 or 200 or 500 applications putting and getting, he is still using a single channel.

Enlighten me, O Wise Ones.


I'm not feeling very wise at the moment

I suspect that I, like others, didn't read back through the thread and therefore notice the change...

...so, good spot SAFraser, and I shall now split this thread.
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
hunterKillerz
PostPosted: Tue Jun 22, 2010 5:13 pm    Post subject: Reply with quote

Apprentice

Joined: 16 Jun 2010
Posts: 40

SAFraser wrote:
I wish he had started a different thread for the file transfer questions...

On the connection question: What am I missing here? It appears he has an app running on an MQ server and he is putting into a remote queue (serviced, of course, by a sender/receiver pair). Why are we giving him advice about limiting channel connections? It doesn't matter if he has 1 or 200 or 500 applications putting and getting, he is still using a single channel.

Enlighten me, O Wise Ones.



Yes, you are right, so instead of limiting channel connections, can we limit application connection to QM?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » General IBM MQ Support » MQPUT/MQGET
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.