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 » WebSphere Message Broker (ACE) Support » Sample usage of BLOB INOUT parameter from java method.

Post new topic  Reply to topic
 Sample usage of BLOB INOUT parameter from java method. « View previous topic :: View next topic » 
Author Message
ghoshly
PostPosted: Wed May 07, 2014 6:16 am    Post subject: Sample usage of BLOB INOUT parameter from java method. Reply with quote

Partisan

Joined: 10 Jan 2008
Posts: 333

Hi,

If a INOUT parameter is of type BLOB from Java method, then its equivalent is byte[][].

When I am trying to assign byte[] values inside byte[][] array, after single assignment I am getting ArrayIndex out of bound exception.

Can someone point me to some working example of byte[][] which is being used as INOUT parameter from static java method.

please as I have limited java knowledge.
Back to top
View user's profile Send private message
McueMart
PostPosted: Wed May 07, 2014 7:46 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

So you are trying to pass a BLOB (byte[]) to a java function, do something with it, and then return a modified BLOB (byte[]) back to the calling ESQL function?

I haven't done this before (and the infocenter, very kindly of it, doesn't seem to mention this in the slightest...) but my guess would be that:

byte[0] contains the input byte[] and
byte[1] will contain the output byte[]

e.g. you should do:

byte[] myOutputBytes = new byte[] {0x01,0x02,0x03};
byte[1] = myOutputBytes;
Back to top
View user's profile Send private message
mgk
PostPosted: Wed May 07, 2014 12:12 pm    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Actually for Out and Inout BLOBs (byte[]s) the parameter will be a byte[] of length 1. For an Out param called p1, p1[0] will always be null on input - you are supposed to replace the null with the byte[] to return. For an Inout param called p2, p2[0] may be null if no value was passed to the parameter, or it will be a valid byte[] containing the ESQL BLOB passed in.
If you then change p2[0] to a different byte[], then the new value will be returned back to ESQL.

For example,

Code:
//ignore any value passed in and just return a new byte[]
public static void byteArrayInOutTest( byte[][] pInOut ) {
  pInOut[0] = new byte[] { 0xF,0xE,0xD,0xC,0xB,0xA,9,8,7,6,5,4,3,2,1,0};
}


Kind regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed May 07, 2014 12:35 pm    Post subject: Reply with quote

Grand High Poobah

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

There you have it from the horse's mouth....
In both cases the byte[] will be in byte[0] of byte[][]

I guess it has to do with the "boxing" that affects all Java parms being passed from ESQL...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
McueMart
PostPosted: Thu May 08, 2014 1:05 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

Ahhh interesting! Thats for that clarification mgk (If only the infocenter was as clear as that description... )
Back to top
View user's profile Send private message
ghoshly
PostPosted: Thu May 08, 2014 4:41 am    Post subject: thanks. Reply with quote

Partisan

Joined: 10 Jan 2008
Posts: 333

Thanks all, I'll surely try it out and would come back with snippet, if I am still facing error.
Back to top
View user's profile Send private message
ghoshly
PostPosted: Fri May 09, 2014 3:33 am    Post subject: SOLVED - thanks Reply with quote

Partisan

Joined: 10 Jan 2008
Posts: 333

We are able to use byte[][] as INOUT or OUT parameter from a java method to esql.

We had to return multiple byte arrays (BLOB)s hence we utilized System.arraycopy to summarize multiple byte[] as below.



Code:
         System.arraycopy(blbTotalResultSet, 0, blbTempResultSet, 0, blbTotalResultSet.length);
         System.arraycopy(blbCurrentResultSet, 0, blbTempResultSet, blbTotalResultSet.length, blbCurrentResultSet.length);
         blbTotalResultSet = blbTempResultSet;   


Its working on my purpose. Let me know if you foresee any major impact on this approach OR how we can return multiple byte[] at once.
Back to top
View user's profile Send private message
McueMart
PostPosted: Fri May 09, 2014 8:06 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

Sounds ok to me. How does the ESQL (the calling function) know how to 'split' the BLOB which is returned, into the set of sub-BLOBs? Are they fixed lengths - or is there some separator byte?
Back to top
View user's profile Send private message
ghoshly
PostPosted: Sun May 11, 2014 10:38 am    Post subject: Reply with quote

Partisan

Joined: 10 Jan 2008
Posts: 333

In my case, the result was XML. So I could just parse the BLOB into XML.


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 » WebSphere Message Broker (ACE) Support » Sample usage of BLOB INOUT parameter from java method.
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.