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 » how to increase a buffer size in java to put messege in Q

Post new topic  Reply to topic
 how to increase a buffer size in java to put messege in Q « View previous topic :: View next topic » 
Author Message
kulkarni
PostPosted: Mon Jun 05, 2006 10:48 pm    Post subject: how to increase a buffer size in java to put messege in Q Reply with quote

Newbie

Joined: 05 Jun 2006
Posts: 2

Hi
I am trying to a message in a queue using java program..but in queue the entire message is not putting..So i dont know where to set buffer size in java program..or any other solution other than setting buffer size..
plz tell me..
_________________
i am trying to put a message in a local q using java program..but the message is too large, so it is not putting entire thing in the q.So i want to know where to exactly set the buffer size in the java program..plz help me..
Back to top
View user's profile Send private message
8davitt
PostPosted: Mon Jun 05, 2006 11:49 pm    Post subject: Reply with quote

Apprentice

Joined: 06 Feb 2003
Posts: 37
Location: Seated in front of monitor

You did not indicate what error message you are seeing. If the message is arriving at the target queue then it is likely to be an application problem. There are a few things you can check first.

o Ensure the Queue Manager can handle the message.
$ runmqsc <QMGRNAME>
dis qmgr
look for MAXMSGL

o Ensure the queue can handle the message
$ runmqsc <QMGRNAME>
dis ql(QNAME)
look for MAXMSGL

o If you are using a client connection nesure the channel that is used can handle the message
$ runmqsc <QMGRNAME>
dis channel(CHLNAME) chltype(SVRCONN) ALL
look for MAXMSGL

However as I said previously if a message is arriving on the queue without an error message returned it is likely to be an application problem.

Perhaps if you include the any error message or a snippet fromyour code someone maybe able to see the problem.

/s
Back to top
View user's profile Send private message
8davitt
PostPosted: Tue Jun 06, 2006 12:15 am    Post subject: Reply with quote

Apprentice

Joined: 06 Feb 2003
Posts: 37
Location: Seated in front of monitor

I do not know how to submit a sample to Java samples so I have mebedded a simple program which will allow you to put different size messages to a queue.

$ javac BigPutbmode.java
$ java BigPutbmode <QMGRNAME> <QNAME> <MSGSIZE> <TRACE>

defaults are default queue manager, SYSTEM.DEFAULT.LOCAL.QUEUE, 512 and trace off

/s

// Code ========================================

import java.io.*;
import com.ibm.mq.*; // Include the MQ package

public class BigPutBmode
{

private static String qManager = ""; // define name of queue manager object to
// connect to.
private static String qName = "SYSTEM.DEFAULT.LOCAL.QUEUE";

private MQQueueManager qMgr; // define a queue manager object
private static int msgSize=512;
private static boolean traceOn = false;

// When the class is called, this initialisation is done first.

public static void main(String args[]) {
System.out.println("BigPutBmode>> args.length = " + args.length);
for (int i =0 ; i <args.length ; i++) {
if (0==i) {
qManager = args[i];
}
if (1==i) {
qName = args[i];
}
if (2==i) {
msgSize = Integer.parseInt(args[i]);
}
if (3==i) {
traceOn = true;
}
}
System.out.println("\tQMGR:\t" + qManager + "\n" +
"\tQ :\t" + qName + "\n" +
"\tLen :\t" + msgSize);

if (traceOn) {
System.out.println("\tTracing is On");
try {
FileOutputStream tf = new FileOutputStream("test.trc");
MQEnvironment.enableTracing(5,tf);
}
catch (IOException e) {
MQEnvironment.enableTracing(5);
}
}
new BigPutBmode();
}


public BigPutBmode()
{

try {
// Create a connection to the queue manager
qMgr = new MQQueueManager(qManager);

// Set up the options on the queue we wish to open...
// Note. All MQ Options are prefixed with MQC in Java.

int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT ;

// Now specify the queue that we wish to open, and the open options...

MQQueue system_default_local_queue =
qMgr.accessQueue(qName,
openOptions,
null, // default q manager
null, // no dynamic q name
null); // no alternate user id


// Define a simple MQ message, and initialise it in UTF format..

MQMessage hello_world = new MQMessage();
byte b[] = new byte[msgSize];
for (int i=0;i<msgSize;i++) {
b[i]= (byte)i;
}
hello_world.write(b);
hello_world.writeUTF("Hello World!");

// specify the message options...

MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults, same
// as MQPMO_DEFAULT constant

// put the message on the queue

system_default_local_queue.put(hello_world,pmo);

// get the message back again...
// First define a MQ message buffer to receive the message into..

MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = hello_world.messageId;

// Set the get message options..

//MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults
// same as MQGMO_DEFAULT

// get the message off the queue..

//system_default_local_queue.get(retrievedMessage,
// gmo,
// 100); // max message size

// And prove we have the message by displaying the UTF message text

//String msgText = retrievedMessage.readUTF();
//System.out.println("The message is: " + msgText);

// Close the queue

system_default_local_queue.close();

// Disconnect from the queue manager

qMgr.disconnect();

}

// If an error has occured in the above, try to identify what went wrong.
// Was it an MQ error?

catch (MQException ex)
{
System.out.println("An MQ error occurred : Completion code " +
ex.completionCode +
" Reason code " + ex.reasonCode);
}
// Was it a Java buffer space error?
catch (java.io.IOException ex)
{
System.out.println("An error occurred whilst writing to the message buffer: " +
ex);
}

} // end of start

} // end of sample
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jun 07, 2006 6:07 pm    Post subject: Reply with quote

Grand High Poobah

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

Usually it is not healthy to mix the 2 methods in the same message:
Quote:
hello_world.write(b);
hello_world.writeUTF("Hello World!");

Reading the Using Java manual you will see that the writeUTF method creates/writes a few extra bytes to the begining of the message.
You cannot and should not treat those methods as you would while using java.io (we are not talking about streams here).

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
8davitt
PostPosted: Wed Jun 07, 2006 11:44 pm    Post subject: Reply with quote

Apprentice

Joined: 06 Feb 2003
Posts: 37
Location: Seated in front of monitor

"Guilty Your Honour".

Looks like I got caught modifying that well known copyrighted HelloWorld program. I used to cheat with my homework too.

/s
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » how to increase a buffer size in java to put messege in Q
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.