• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

MQ for Java

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to write a program in Java using native MQ API's and the program is supposed to get messages off a queue and format the message we get.I have been trying to find on the net how to do that,as I want to format the strings as I receive them from the queue.
Like the first 8 characters I get from the MQ Queue,I want to put certain delimiters around them and then around the next 6 chars,different delimiters and so on for about 61 chars from the queue.I tried doing retrivedMessage.readString(8) but that is only for the first 8,how do I get to the next 6 and so on also I tried retrivedMessage.readUTF() but that retrieves the whole message from the queue.whereas I want to format the message into different sets with delimiters to differentiate each of them.my sample code is below:
MQMessage retrievedMessage = new MQMessage ( );
mqQ.get ( retrievedMessage,gmo);
msgText = retrievedMessage.readUTF( );
if ( retrievedMessage.getMessageLength() != 0){
String fl1 = retrievedMessage.readString(8);
fl1 = "DT" + fl1 + "DT";
//Substring doesn't work in MQ,this next line throws an error.
String fl2 = retrievedMessage.substring(8,16);
fl2 = "NT" + fl2 + "NT";
}
else
System.out.println(" No data Available ");
How can I get to the next set of values on the queue and format them.It doesn't recognize the substring defn in MQ.
Any help??
Thanks in advance..
Ann
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ann,
Am slightly confused on what actually you want to do.
(1) How are the messages avbl on the queue ? As strings or as characters ?
(2) How do you want to format the message exactly ? Do you want to a read a string off the queue and the delimit it in a particular fashion ?
If you want to retrieve string messages off the queue and then format them, the first step would be to separate the reading of queue and formatting -> this makes it much simpler to code.
If you can give some details, I will see if I can be of any help.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic