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 » Recieved message characterSet?

Post new topic  Reply to topic
 Recieved message characterSet? « View previous topic :: View next topic » 
Author Message
mathilda
PostPosted: Wed May 16, 2007 9:25 am    Post subject: Recieved message characterSet? Reply with quote

Novice

Joined: 16 May 2007
Posts: 16
Location: Sofia, Bulgaria

Hello,

I try this simple example to send and receive message from Queue ( code bellow) . Everything is OK, but when receiver get message maybe try to write to file.
If i send Cyrillic or Chinese symbols in message (for example: Send Chinese symbols and set 950 for CCSID) receiver must know what character encoding is used to get bytes for example to write to file.
Is there any chance receiver to know CCSID of message?

BR

to send :
........
Code:

     MQQueueConnectionFactory connectionFactory = null;
    QueueConnection connection = null;
    QueueSession session = null;
    QueueSender sender = null;
    QueueReceiver receiver = null;
    Queue myQueue = null;

    try {

      connectionFactory = new MQQueueConnectionFactory();
      connectionFactory.setHostName(hostName);
      connectionFactory.setQueueManager("QM_manager");
      //connectionFactory.setChannel(channelName); //?????????
      connectionFactory.setPort(port);
      connectionFactory.setTransportType(JMSC.MQJMS_TP_BINDINGS_MQ);
      connectionFactory.setCCSID(ccsid);
      connection = connectionFactory.createQueueConnection();
      session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      myQueue = session.createQueue(queueName);
        ((MQQueue) myQueue).setTargetClient(1);


        sender = session.createSender(myQueue);
       TextMessage message = session.createTextMessage();
        //System.out.println("ddd: " + message.CHARSET_PROPERTY);        message.setStringProperty("JMS_IBM_Character_Set",String.valueOf(1200));
        String text = "Some text";
        message.setText(text);
        sender.send(message);
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
    finally {
      try {
        if ( sender != null ) {
          sender.close();
        }
        if ( receiver != null ) {
          receiver.close();
        }
        if ( session != null ) {
          session.close();
        }
        if ( connection != null ) {
          connection.close();
        }
      }
      catch (Exception ex) {
      }
    }
  }
...................


to Receive :

Code:

     MQQueueConnectionFactory connectionFactory = null;
    QueueConnection connection = null;
    QueueSession session = null;
    QueueSender sender = null;
    QueueReceiver receiver = null;
    Queue myQueue = null;

    try {

      connectionFactory = new MQQueueConnectionFactory();
      connectionFactory.setHostName(hostName);
      connectionFactory.setQueueManager("QM_manager");
      //connectionFactory.setChannel(channelName); //?????????
      connectionFactory.setPort(port);
      connectionFactory.setTransportType(JMSC.MQJMS_TP_BINDINGS_MQ);
      connectionFactory.setCCSID(ccsid);
      connection = connectionFactory.createQueueConnection();
      session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      myQueue = session.createQueue(queueName);
        ((MQQueue) myQueue).setTargetClient(1);


        receiver = session.createReceiver(myQueue);


        JMSTextMessage recMsg =  (JMSTextMessage )receiver.receive(1);

       String recString = recMsg.getText();

    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
    finally {
      try {
        if ( sender != null ) {
          sender.close();
        }
        if ( receiver != null ) {
          receiver.close();
        }
        if ( session != null ) {
          session.close();
        }
        if ( connection != null ) {
          connection.close();
        }
      }
      catch (Exception ex) {
      }
    }
  }
...................

_________________
On any given Sunday you're gonna win or you're gonna lose. The point is
- can you win or lose like a man?
Back to top
View user's profile Send private message
marcin.kasinski
PostPosted: Wed May 16, 2007 10:18 am    Post subject: Re: Recieved message characterSet? Reply with quote

Sentinel

Joined: 21 Dec 2004
Posts: 850
Location: Poland / Warsaw

You dont need to know remote application CCSID.

When you get message in your application just set CONVERT option.

In this situation QMGR you are connected to convert input message into your application CCSID.
_________________
Marcin
Back to top
View user's profile Send private message Visit poster's website
mathilda
PostPosted: Wed May 16, 2007 10:26 am    Post subject: Reply with quote

Novice

Joined: 16 May 2007
Posts: 16
Location: Sofia, Bulgaria

To set CONVERT on channel?
_________________
On any given Sunday you're gonna win or you're gonna lose. The point is
- can you win or lose like a man?
Back to top
View user's profile Send private message
marcin.kasinski
PostPosted: Wed May 16, 2007 10:44 am    Post subject: Reply with quote

Sentinel

Joined: 21 Dec 2004
Posts: 850
Location: Poland / Warsaw

mathilda wrote:
To set CONVERT on channel?


You can do it on channel.
_________________
Marcin
Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Wed May 16, 2007 7:47 pm    Post subject: Reply with quote

Grand High Poobah

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

OK guys get real....
Mathilda is talking about JMS so here it goes...

a) set the CCSID x on the qcf object. So the qmgr will know you are sending textmessages in CCSID x which may be different from the ccsid of the qmgr...

b) on the receiving qmgr do nothing. JMS TextMessage does automatically a get with Convert... The user has nothing to do....
If the receiving app has a different CCSID than the receiving qmgr see point a...

c) make sure there is a default translation existing between the receiving qmgr CCSID and the message CCSID.

d) as a word of caution: make sure you have the full client installed and the library/jar files being pointed at are the original ones in their respective original directory otherwise you might get a CCSID conversion not supported...

Enjoy


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mathilda
PostPosted: Wed May 16, 2007 11:43 pm    Post subject: Reply with quote

Novice

Joined: 16 May 2007
Posts: 16
Location: Sofia, Bulgaria

Thanks guys
If i understand correctly, when use TextMessage and send message - i set CCSID x of message and problem maybe is the conversion between CCSID of message and CCSID of QMNGR?
When receive message i set CCSID z on MQQueueConnectionFactory - problem maybe is conversion between CCSID on connectionFactory and CCSID on QMNGR?
And last - because for the moment i don't need to use channel, but only on channel properties i find property CONVERTED - when i use TextMessage (MQSTR) is always have CONVERTED is ON or is another way to switch on/of of this property?

Thanks
_________________
On any given Sunday you're gonna win or you're gonna lose. The point is
- can you win or lose like a man?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu May 17, 2007 5:30 pm    Post subject: Reply with quote

Grand High Poobah

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

If you want not to convert use a bytes message....
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

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