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 Discussion » Message ID not retained between remote and local queues

Post new topic  Reply to topic Goto page Previous  1, 2, 3
 Message ID not retained between remote and local queues « View previous topic :: View next topic » 
Author Message
mqjeff
PostPosted: Thu Sep 10, 2015 6:06 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The issues with Byte are why the MQ API uses the byte primitive instead of the Byte class...

There are various ways to convert a byte[] into a hex string, including printf options....
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
tczielke
PostPosted: Thu Sep 10, 2015 6:06 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

mqjeff wrote:
tczielke wrote:
It looks like in Java there isn't a primitive type that corresponds to the unsigned char in C. The closest one I see is the byte, like you mentioned which is the following:

byte 8 bits -128 - +127

So if a Java application is trying to display individual bytes in the MsgId using a byte primitive, it looks like it would show a negative number for any byte >= 80.

A little deficient on the Java side to me, if that is the case.


Again, the MQ Java API (not the JMS API) says that the MsgID and CorrelID are byte arrays - byte[]. And, yeah, a Java byte is an 8 bit byte, not anything bigger. But unsigned, so you get 0-254, not -128 to +127.


In both of the Java books that I use ("Java in a Nutshell" and "Head First Java"), the Java primitive of byte is defined with a range of -128 - +127. That is what I was referring to.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
tczielke
PostPosted: Thu Sep 10, 2015 6:14 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

fjb_saper wrote:
Even more deficient in java is the decode function of Byte, Integer, etc...
It only accepts positive values...
So if you have a byte that's above 7F you get a number format exception...
The answer is use the Integer.decode function and cast to byte...

For extracting the hex string you can use shift and bit masks so that you never have a value over 15...

Have fun


I did run across a similar issue with the MQOptions java program in the MH06 supportpac, when I wanted to take an input 4 byte hex number and convert it to an integer primitive. Java is a little quirky that way, but part of it is probably me just getting used to the language.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Thu Sep 10, 2015 10:58 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9399
Location: US: west coast, almost. Otherwise, enroute.

mqjeff wrote:
tczielke wrote:
It looks like in Java there isn't a primitive type that corresponds to the unsigned char in C. The closest one I see is the byte, like you mentioned which is the following:

byte 8 bits -128 - +127

So if a Java application is trying to display individual bytes in the MsgId using a byte primitive, it looks like it would show a negative number for any byte >= 80.

A little deficient on the Java side to me, if that is the case.


Again, the MQ Java API (not the JMS API) says that the MsgID and CorrelID are byte arrays - byte[]. And, yeah, a Java byte is an 8 bit byte, not anything bigger. But unsigned, so you get 0-254, not -128 to +127.

An MQBYTE is just a string of bits, neither signed nor unsigned.

A Java primitive data type byte is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive).

Incompatible. Whose oversight is that?
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Sep 10, 2015 9:43 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

bruce2359 wrote:
mqjeff wrote:

Again, the MQ Java API (not the JMS API) says that the MsgID and CorrelID are byte arrays - byte[]. And, yeah, a Java byte is an 8 bit byte, not anything bigger. But unsigned, so you get 0-255, not -128 to +127.

An MQBYTE is just a string of bits, neither signed nor unsigned.

A Java primitive data type byte is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive).

Incompatible. Whose oversight is that?


My guess is that MQBYTE predates Java which was added to MQ around V5 (might be wrong there though)
For those of us who cross ourselves when we have to work with the spawn of the devil (Java) using MQBYTE in C/C++ represents no problem at all.
Even in other languages it is no problem. As I said, Java is ....
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
tczielke
PostPosted: Fri Sep 11, 2015 4:32 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

This is just a limitation of the Java language, as far as I know. The only 8 bit primitive that they give you to work with is the byte primitive, and it has a range of -128 - +127. In fact, all their integer primitives (byte, short, int, long) assume a sign. Not sure why they didn't see the need to also support unsigned integer primitives.
_________________
Working with MQ since 2010.


Last edited by tczielke on Fri Sep 11, 2015 7:23 am; edited 1 time in total
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Sep 11, 2015 4:48 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

just because they assume a sign doesn't mean you have to treat it as a sign bit.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Sep 11, 2015 7:14 am    Post subject: Reply with quote

Grand High Poobah

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

mqjeff wrote:
just because they assume a sign doesn't mean you have to treat it as a sign bit.

No but it means that the class does not provide you with the default manipulation objects for an unsigned content and that you have to do some of that manipulation yourself... or build a workaround...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Fri Sep 11, 2015 7:30 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

fjb_saper wrote:
mqjeff wrote:
just because they assume a sign doesn't mean you have to treat it as a sign bit.

No but it means that the class does not provide you with the default manipulation objects for an unsigned content and that you have to do some of that manipulation yourself... or build a workaround...


If you want to do anything other than what amounts to memcopy into an unsigned byte.


_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2, 3 Page 3 of 3

MQSeries.net Forum Index » General Discussion » Message ID not retained between remote and local queues
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.