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 Java / JMS » Reading MQXMIT JMS message

Post new topic  Reply to topic
 Reading MQXMIT JMS message « View previous topic :: View next topic » 
Author Message
mangelos
PostPosted: Thu Sep 21, 2006 5:09 am    Post subject: Reading MQXMIT JMS message Reply with quote

Novice

Joined: 06 Jul 2006
Posts: 14
Location: Novi Sad, Serbia

Hi guys,

I need to extract an info about destination(remote) queue from message that resides on transmission queue.

scenario : i've put a message with jms client(i used QueueSender) to the remote definition ; message went to the transmission queue and stayed there (channels are down); i need to get that message back and somehow extract a name of a remote queue

first, i tried to get the message with QueueBrowser but as i said , i don't know how to find name of the remote queue

secondly, i tried to open queue with Java base and get message as MQMessage but when i try to read MQXQH structure i get exception in first line ( retrievedMessage.readString(4) ) saying

java.io.UnsupportedEncodingException: Cp437

any suggestions?
Back to top
View user's profile Send private message MSN Messenger
jefflowrey
PostPosted: Thu Sep 21, 2006 5:12 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Just use amqsbcg to browse the queue.

The first section of the message will be the MQXQH, and will contain the various fields defined for that header in the Application Programming Reference.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mangelos
PostPosted: Thu Sep 21, 2006 10:50 am    Post subject: Reply with quote

Novice

Joined: 06 Jul 2006
Posts: 14
Location: Novi Sad, Serbia

Thanx Jeff for your reply,

i'm sorry, i guess i wasn't clear enough

as you said, amqsbcg shows me "message descriptor" and "message" part

and what i need is the name of the remote queue,
which is only in the "message" part.
later, i would use that name in a filter of some sort

i thought there would be something like:
'retrievedMessage.getRemoteQueueName()' or something like that ... you get the picture

to clarify even more
for example, i need to get info (in bold) as a property


**** Message ****

length - 440 bytes

00000000: 5851 4820 0100 0000 512E 514D 3220 2020 'XQH ....Q.QM2 '
00000010: 2020 2020 2020 2020 2020 2020 2020 2020 ' '
00000020: 2020 2020 2020 2020 2020 2020 2020 2020 ' '
00000030: 2020 2020 2020 2020 514D 3220 2020 2020 ' QM2 '
00000040: 2020 2020 2020 2020 2020 2020 2020 2020 ' '
00000050: 2020 2020 2020 2020 2020 2020 2020 2020 ' '



i'll be browsing those messages in a cluster transmission queue



p.s.
i forgot to mention that i'm using MQ 5.3 Win CSD12
Back to top
View user's profile Send private message MSN Messenger
fjb_saper
PostPosted: Thu Sep 21, 2006 2:24 pm    Post subject: Re: Reading MQXMIT JMS message Reply with quote

Grand High Poobah

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

mangelos wrote:

java.io.UnsupportedEncodingException: Cp437
any suggestions?


Encoding in MQ does not equal to encoding in XML!

Set the value to 0 or read the manual and use one of the appropriate literals to set the value.

437 is a CCSID value. Your message is malformed! Just because the field will allow any integer value does not mean that any value you set there is meaningful
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mangelos
PostPosted: Thu Sep 21, 2006 11:47 pm    Post subject: Reply with quote

Novice

Joined: 06 Jul 2006
Posts: 14
Location: Novi Sad, Serbia

excuse me for my ignorance

fjb_saper, thanx for pointing out the CCSID issue

in a hurry, i've missed those topics

Java was the problem (java settings actually), a different charsets.jar was included

I have one more question.
Can i switch beetwen JMS Message and MQ Message?
Do i need a custom code for mapping or there is an other way?
Back to top
View user's profile Send private message MSN Messenger
fjb_saper
PostPosted: Fri Sep 22, 2006 2:52 am    Post subject: Reply with quote

Grand High Poobah

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

Have 2 destinations defined for the same queue (JMS).
  1. Standard JMS queue defined like
    "queue://myqgmr/myqueue"
  2. Standard MQ queue defined like
    "queue://myqmgr/myqueue?targetClient=1"


This should help you out. In WAS setup the attribute (targetClient) has a drop down and accepts 1 of 2 values: JMS or MQ. I believe that is quite clear.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Fri Sep 22, 2006 3:27 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Also, there's a very long page in the Using Java manual dedicated to how JMS messages are mapped by the WebSphere MQ JMS Provider onto MQ messages - and vice-versa.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mangelos
PostPosted: Mon Sep 25, 2006 11:19 pm    Post subject: Reply with quote

Novice

Joined: 06 Jul 2006
Posts: 14
Location: Novi Sad, Serbia

greetings,

after a few days, i still have the same problem,
so.. back to the drawing board

Quote:
Also, there's a very long page in the Using Java manual dedicated to how JMS messages are mapped by the WebSphere MQ JMS Provider onto MQ messages - and vice-versa.


i've read it and i don't understand it so i need your help guys

i tried to put some user properties in a jms message (i used setStringProperty() )
but i don't know how to read them

I receive a message with a QueueReceiver and when i do getStringProperty("blabla") i get null

in WebSphere MQ Explorer i can see those properties.

One more thing, if i get messages with QueueBrowser and receive an Enumeration vector, is it possible to typecast an enumeration element as a message?
Back to top
View user's profile Send private message MSN Messenger
fjb_saper
PostPosted: Tue Sep 26, 2006 2:39 am    Post subject: Reply with quote

Grand High Poobah

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

It seems to me like you are confusing 2 things. The MQ message which has limited properties when read in JMS, and the JMS message with the usr folder in the RFH which holds the properties.

So if you are trying getStringProperty("mycolor") and expect the answer to be "Big blue" you must have a JMS message where you set that property.

If that message has been put on a queue as MQ message the RFH header that holds the properties gets stripped. Tough luck this is the way the product works...

Now you can retrieve an enumeration of the properties from the message in JMS. But you cannot cast any of those as a message... I would suggest you retrieve an enumeration of the property keys and in a loop write the key and it's value to a log along with the message content. This way you will understand and learn better what is going on behind the covers...

And please read the "Using Java" manual again ...and again...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mangelos
PostPosted: Tue Sep 26, 2006 3:43 am    Post subject: Reply with quote

Novice

Joined: 06 Jul 2006
Posts: 14
Location: Novi Sad, Serbia

saper, i really do appreciate your help

Quote:
And please read the "Using Java" manual again ...and again...

i'm doing my best, believe me

messages have been put on a queue as JMS messages

idea was to get stuck messages back from transmission queue
and to programmatically get their destination and data they were carrying

i wanted to extract that info(name of the remote queue and data) by getting messages from a queue as JMS messages
but then i didn't know how to take that info from a jms message
(i've tried to set some properties and to read them later on but no success)

then i tried to get those messages as MQ messages and i've made a partial success
i can read a transmission header, embeded MQMD, MQRFH2 header and parse the rest of the message but that seemed to be too much trouble and code

that's why i asked you guys for a more "sophisticated" solution

so, how would you extract an information (remote queue name and actual message data) from a JMS Message that has been picked up from a transmission queue?
Back to top
View user's profile Send private message MSN Messenger
jefflowrey
PostPosted: Tue Sep 26, 2006 3:44 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If the Using Java page I linked to doesn't show that the Destination is also put into the MQRFH2, then the only place it's going to be is in the MQXQH.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Sep 26, 2006 3:46 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

But you really don't want to do this in your application.

You may want to build an administrative tool to do this, but it should not be part of your business logic in any way to read the XMITQ.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mangelos
PostPosted: Tue Sep 26, 2006 4:29 am    Post subject: Reply with quote

Novice

Joined: 06 Jul 2006
Posts: 14
Location: Novi Sad, Serbia

yes, reading the XMITQ is meant for an administrative tool[/quote]
Back to top
View user's profile Send private message MSN Messenger
fjb_saper
PostPosted: Tue Sep 26, 2006 2:58 pm    Post subject: Reply with quote

Grand High Poobah

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

I don't like the term stuck in an XMITQ. Messages are never stuck in an XMITQ.
The channel might be in doubt or retrying.
Or you might have a poison message in the XMITQ...

By poison message I mean here a message that violates the properties of the channel. (msglength > max chl length etc...). You should see some mention in the error logs about a case like this...


If this is a problem with the channel you need to resolve it through the channel.

If you want to route differently you can alter the channel the messages are to go through to use the xmit queue where your messages are waiting and then change the channel back to use it's regular xmitq and voila the messages waiting on your earlier xmitq have been sent on their way. (or you can use a utility to just move the messages to the new xmitq as they already have the right format).

Read as well the intercommunications manual and look into the use of qmgr aliases and such.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mangelos
PostPosted: Tue Sep 26, 2006 10:28 pm    Post subject: Reply with quote

Novice

Joined: 06 Jul 2006
Posts: 14
Location: Novi Sad, Serbia

i admit that "stuck" isn't the best suiting term

a situation is that i'm in a cluster environment and
there is no permanent connection between cluster members
so, in case of a broadcast ( publish/subscribe method isn't used)
some messages are left in a cluster transmission queue

i want to a make a tool to analyze those messages (to see which queue hasn't received them) and, if needed, to take them off the queue and find an alternate means of transport ( a car, a homing pigeon, .. )
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Reading MQXMIT JMS message
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.