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 » User defined properties to be mapped from JMS to MQ

Post new topic  Reply to topic Goto page Previous  1, 2
 User defined properties to be mapped from JMS to MQ « View previous topic :: View next topic » 
Author Message
anilit99
PostPosted: Tue Jul 07, 2009 3:01 am    Post subject: Reply with quote

Voyager

Joined: 28 May 2009
Posts: 75
Location: London, UK

extract from the Using Java thing :
Code:
catch (JMSException je) {
    System.err.println("Caught JMSException");

    // Check for linked exceptions in JMSException
    Throwable t = je;
    while (t != null) {
        // Write out the message that is applicable to all exceptions
        System.err.println("Exception Msg: " + t.getMessage());
        // Write out the exception stack trace
        t.printStackTrace(System.err);

        // Add on specific information depending on the type of exception
        if (t instanceof JMSException) {
            JMSException je1 = (JMSException) t;
            System.err.println("JMS Error code: " + je1.getErrorCode());

            if (t instanceof JmsExceptionDetail){
                JmsExceptionDetail jed = (JmsExceptionDetail)je1;
                System.err.println("JMS Explanation: " + jed.getExplanation());
                System.err.println("JMS Explanation: " + jed.getUserAction());
            }
        } else if (t instanceof MQException) {
            MQException mqe = (MQException) t;
            System.err.println("WMQ Completion code: " + mqe.getCompCode());
            System.err.println("WMQ Reason code: " + mqe.getReason());
        } else if (t instanceof JmqiException){
            JmqiException jmqie = (JmqiException)t;
            System.err.println("WMQ Log Message: " + jmqie.getWmqLogMessage());
            System.err.println("WMQ Explanation: " + jmqie.getWmqMsgExplanation());
            System.err.println("WMQ Msg Summary: " + jmqie.getWmqMsgSummary());
            System.err.println("WMQ Msg User Response: "
                               + jmqie.getWmqMsgUserResponse());
            System.err.println("WMQ Msg Severity: " + jmqie.getWmqMsgSeverity());
        }

        // Get the next cause
        t = t.getCause();
    }
}


I am a total newbie here, even then I couldnt stop myself from appreciating the effort these MQ guys had put into this error handling !!!
_________________
"I almost care !"
Back to top
View user's profile Send private message
dotaneli
PostPosted: Tue Jul 07, 2009 3:16 am    Post subject: Reply with quote

Voyager

Joined: 19 Oct 2005
Posts: 99
Location: Israel

Great, thanks.
after adding:
System.err.println("JMS Linked exception: " + e.getLinkedException());
in the catch area, i got:

JMS Linked exception: com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2142

mqrc 2142 gives me:

2142 0x0000085e MQRC_HEADER_ERROR

which probarly means that i'm messing with the header, and shoudln't do it.

Only question is - when i don't set the format field, why can't rfhutil see the message?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jul 07, 2009 3:40 am    Post subject: Reply with quote

Grand High Poobah

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

O.K.
So you NEED TO STOP MIXING JMS and MQ Base style programming. THEY'RE NOT COMPATIBLE.

The decision on whether to use a JMS header(RFH) is being made with the targetClient property on the Destination (JMS).

Setting the format field is a java base thing.
Also if you ever create an RFH header in java base (nonsense in my opinion, write a JMS program!) make sure you respect the corresponding byte alignment laws...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Tue Jul 07, 2009 3:51 am    Post subject: Reply with quote

Grand High Poobah

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

dotaneli wrote:
which probarly means that i'm messing with the header, and shoudln't do it.


It certainly means you're doing it wrong. The header has some quite specific rules, which is why most Java apps use JMS to manipulate it.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
dotaneli
PostPosted: Tue Jul 07, 2009 3:56 am    Post subject: Reply with quote

Voyager

Joined: 19 Oct 2005
Posts: 99
Location: Israel

Okay guys, 10x.

I rewrote the code, since the code given to me was the client's code.
It now works perfectly.

The other thing I need to know is how do i read or set the RFH2 header using MQ Base?
I know - JMS is a preffered way for that, but the client insists on both MQ Base and JMS implementation..

So please - a reference to a good step by step documentation would be valued..

Thank you!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jul 07, 2009 4:01 am    Post subject: Reply with quote

Grand High Poobah

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

dotaneli wrote:
Okay guys, 10x.

I rewrote the code, since the code given to me was the client's code.
It now works perfectly.

The other thing I need to know is how do i read or set the RFH2 header using MQ Base?
I know - JMS is a preffered way for that, but the client insists on both MQ Base and JMS implementation..

So please - a reference to a good step by step documentation would be valued..

Thank you!


Have you read the programmer's manual and reference ? Not just Using Java!
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
dotaneli
PostPosted: Tue Jul 07, 2009 4:16 am    Post subject: Reply with quote

Voyager

Joined: 19 Oct 2005
Posts: 99
Location: Israel

Once, long time ago..

Do you happen to have a link to the RedBook download?

10x..

Plus - Why is the MQHeaders class unavailable? It should make life so much easier, but i cannot find the relevant jar. Nor is it available online..
.
Back to top
View user's profile Send private message
anilit99
PostPosted: Tue Jul 07, 2009 4:24 am    Post subject: Reply with quote

Voyager

Joined: 28 May 2009
Posts: 75
Location: London, UK

Quote:
The other thing I need to know is how do i read or set the RFH2 header using MQ Base?


I got this from the link I posted earlier. I didnt try this one, but looks like it worked for so many people.

Code:
public MQMessage buildRFH2Header(MQMessage msg) throws IOException {

String pubCommand = new String();

pubCommand = "<psc><Command>Publish</Command><Topic>Stock</Topic>" +

"<QMgrName>QFLEXT1</QMgrName><QName>QFLEXT1.A</QName></psc>";

int folderLength = pubCommand.length();

MQMessage theMsg = msg;

theMsg.format = MQC.MQFMT_RF_HEADER_2; // Msg Format

theMsg.writeString(MQC.MQRFH_STRUC_ID); // StrucId

theMsg.writeInt4(MQC.MQRFH_VERSION_2); // Version

theMsg.writeInt4(MQC.MQRFH_STRUC_LENGTH_FIXED_2 + folderLength + 4);

//4) + rf); // StrucLength

theMsg.writeInt4(MQC.MQENC_NATIVE); // Encoding

theMsg.writeInt4(MQC.MQCCSI_DEFAULT); // CodedCharacterSetId

theMsg.writeString(MQC.MQFMT_NONE); // Format (content)

theMsg.writeInt4(MQC.MQRFH_NO_FLAGS); // Flags

theMsg.writeInt4(1208); // NameValueCCSID = UTF-8

theMsg.writeInt4(folderLength);

theMsg.writeString(pubCommand);

theMsg.writeString("begin payload");

return theMsg;

}


Being said that, I totally second this statement from the veteran.
Quote:
So you NEED TO STOP MIXING JMS and MQ Base style programming. THEY'RE NOT COMPATIBLE.


JMS definitely makes life easy.
_________________
"I almost care !"
Back to top
View user's profile Send private message
dotaneli
PostPosted: Tue Jul 07, 2009 4:51 am    Post subject: Reply with quote

Voyager

Joined: 19 Oct 2005
Posts: 99
Location: Israel

thanks, that helps alot.

However, i need to set the <usr> folder, not pub/sub...

can i do in the same manner? what's the exact path i need to build?


thank you
Back to top
View user's profile Send private message
dotaneli
PostPosted: Tue Jul 07, 2009 4:59 am    Post subject: Reply with quote

Voyager

Joined: 19 Oct 2005
Posts: 99
Location: Israel

never mind, it worked...

Now - should be harder to parse it (when reading), right?
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 Page 2 of 2

MQSeries.net Forum Index » IBM MQ Java / JMS » User defined properties to be mapped from JMS to MQ
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.