|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Queue manager conversion and JMS |
« View previous topic :: View next topic » |
Author |
Message
|
cdsw |
Posted: Fri Aug 16, 2024 6:00 am Post subject: Queue manager conversion and JMS |
|
|
Newbie
Joined: 16 Aug 2024 Posts: 3
|
Hello everyone,
I'm currently reviewing character encoding conversion patterns in MQ using JMS.
I was planning to use queue manager conversion to convert all text messages to UTF-8 prior to consuming them.
When I enable queue manager conversion, I get an exception reading messages sent in US-ASCII and converted to UTF-8 in the queue manager.
Code: |
Exception in thread "main" com.ibm.msg.client.jakarta.jms.DetailedMessageFormatRuntimeException: JMSWMQ2002: Failed to get a message from destination 'DEV.QUEUE.1'.
IBM MQ classes for JMS attempted to perform an MQGET; however IBM MQ reported an error.
Use the linked exception to determine the cause of this error
...
Caused by: com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with compcode '1' ('MQCC_WARNING') reason '2119' ('MQRC_NOT_CONVERTED').
... |
Am I misunderstanding something or is this a limitation? Looking at the documentation, reviewing the ccsid.tbl file etc. it seems to be quite a straightforward use of the feature.
Here is a minimal example using the latest MQ docker image.
Code: |
public class Main {
public static void main(String[] args) throws Exception {
JmsFactoryFactory jmsFactoryFactory = JmsFactoryFactory.getInstance(WMQConstants.JAKARTA_WMQ_PROVIDER);
MQQueue destination = (MQQueue) jmsFactoryFactory.createQueue("DEV.QUEUE.1");
destination.setMQMDReadEnabled(true);
destination.setReceiveConversion(WMQConstants.WMQ_RECEIVE_CONVERSION_QMGR);
destination.setReceiveCCSID(CCSID.getCCSID("UTF-8"));
MQConnectionFactory connectionFactory = (MQConnectionFactory) jmsFactoryFactory.createConnectionFactory();
connectionFactory.setHostName("localhost");
connectionFactory.setPort(1414);
connectionFactory.setChannel("DEV.APP.SVRCONN");
connectionFactory.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
connectionFactory.setQueueManager("QM1");
connectionFactory.setAppName("MinimalMQ");
connectionFactory.setStringProperty(WMQConstants.USERID, "app");
connectionFactory.setStringProperty(WMQConstants.PASSWORD, "passw0rd");
try (JMSContext context = connectionFactory.createContext(JMSContext.SESSION_TRANSACTED)) {
TextMessage textMessage = context.createTextMessage("test body");
textMessage.setStringProperty(WMQConstants.JMS_IBM_CHARACTER_SET, "US-ASCII");
JMSProducer producer = context.createProducer();
producer.send(destination, textMessage);
JMSConsumer consumer = context.createConsumer(destination);
Message receivedMessage = consumer.receiveNoWait();
context. c ommit();
}
}
}
|
|
|
Back to top |
|
 |
bruce2359 |
Posted: Fri Aug 16, 2024 7:13 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
What is the ccsid of the qmgr?
What is the ccsid of the client?
What is the ccsid specified in the message descriptor header? _________________ 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 |
|
 |
cdsw |
Posted: Tue Aug 20, 2024 4:59 am Post subject: |
|
|
Newbie
Joined: 16 Aug 2024 Posts: 3
|
bruce2359 wrote: |
What is the ccsid of the qmgr?
What is the ccsid of the client?
What is the ccsid specified in the message descriptor header? |
CCSID of the queue mgr is 819 (ISO-8859-1), seems to be the default setup of the docker image.
CCSID of the client I'm not sure it's set explicitly but as far as I know MQ for JMS always defaults to UTF-8.
The message is sent with CCSID 367 (US-ASCII) and using MQ Explorer is in the queue with that same CCSID.
Setting the option WMQ_RECEIVE_CONVERSION_QMGR I would expect the queue mgr to convert it from US-ASCII to UTF-8 before delivering it to the JMS application. In fact it does so successfully for most combinations of character sets but does not seem to succeed from US-ASCII to UTF-8. |
|
Back to top |
|
 |
gbaddeley |
Posted: Wed Aug 21, 2024 4:09 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
What happens when you don't set
textMessage.setStringProperty(WMQConstants.JMS_IBM_CHARACTER_SET, "US-ASCII");
?
JMS MQ message conversion is a fairly complex topic. Keep the code as simple as possible and only set options if you absolutely need to.
https://www.ibm.com/docs/en/ibm-mq/9.4?topic=conversion-jms-message-types
I thought that almost any source CCSID is convertable to UTF-8. _________________ Glenn |
|
Back to top |
|
 |
cdsw |
Posted: Fri Aug 23, 2024 8:21 am Post subject: |
|
|
Newbie
Joined: 16 Aug 2024 Posts: 3
|
gbaddeley wrote: |
What happens when you don't set
textMessage.setStringProperty(WMQConstants.JMS_IBM_CHARACTER_SET, "US-ASCII");
?
JMS MQ message conversion is a fairly complex topic. Keep the code as simple as possible and only set options if you absolutely need to.
https://www.ibm.com/docs/en/ibm-mq/9.4?topic=conversion-jms-message-types
I thought that almost any source CCSID is convertable to UTF-8. |
Without setting the charset it's sent as UTF-8, which of course works, due to JMS defaults.
The documentation made queue manager conversion look like it was a straightforward feature one might as well enable but indeed it looks like it's trickier than it seems. |
|
Back to top |
|
 |
gbaddeley |
Posted: Sun Aug 25, 2024 3:50 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
cdsw wrote: |
Without setting the charset it's sent as UTF-8, which of course works, due to JMS defaults.
The documentation made queue manager conversion look like it was a straightforward feature one might as well enable but indeed it looks like it's trickier than it seems. |
In a JMS message that was not working with JMS_IBM_CHARACTER_SET, "US-ASCII", are there any UTF-8 characters that are not US-ASCII ? ie. are not single byte character codes in range 0-127 decimal. _________________ Glenn |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|