|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Faced problem in Segmentation in JAVA |
« View previous topic :: View next topic » |
Author |
Message
|
manojkpradhan |
Posted: Wed Feb 23, 2005 1:02 am Post subject: Faced problem in Segmentation in JAVA |
|
|
Apprentice
Joined: 15 Nov 2004 Posts: 25
|
Hi anita ,
I have written the following piece of code . I want to put a big message in a queue. So I am going for segmentation. As far as I understood segmentation I have written the following piece of code and tested it. I am getting reason code 2030 which means MQRC_MSG_TOO_BIG_FOR_Q.
1.>The maximum message length in local que property :4194304(Default)
2.> The size of C.txt file is 5.44 MB
my code is given below:
_____________________________________________________________
import com.ibm.mq.*;
import java.io.*;
public class SegPut
{
public SegPut()
{
MQEnvironment.hostname = "192.168.1.28" ;
MQEnvironment.channel = "SYSTEM.AUTO.SVRCONN" ;
MQEnvironment.port = 1212;
}
MQQueueManager qMgr=null;
MQQueue Fromqueue=null;
public void sendMsg()
{
String qManager = "Test";
String qName = "LQ";
try
{
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES);
MQQueueManager qMgr = new MQQueueManager(qManager) ;
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQPMO_SET_IDENTITY_CONTEXT ;
Fromqueue = qMgr.accessQueue(qName,openOptions,null,null,null);
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_LOGICAL_ORDER|MQC.MQPMO_SET_IDENTITY_CONTEXT | MQC.MQPMO_SYNCPOINT ;
//Create the message buffer
MQMessage outMsg = new MQMessage();
// Set the MQMD format field.
outMsg.format = MQC.MQFMT_STRING ;
outMsg.messageFlags = MQC.MQMF_SEGMENTATION_ALLOWED ;
outMsg.offset = 1024;
//outMsg.setVersion(MQC.MQMD_VERSION_2);
File f = new File("D:\\manoj"+"\\"+qManager+"\\"+"C.txt");
int totalLen = (int)f.length();
System.out.println("The Total len is : " + totalLen );
byte[] b = new byte[totalLen];
FileInputStream fin = new FileInputStream (f);
fin.read(b);
outMsg.write(b);
Fromqueue.put(outMsg, pmo);
System.out.println("MQ Message put on queue");
}
catch (MQException ex)
{
System.out.println("An MQ Error Occurred: Completion Code is :\t" +
ex.completionCode + "\n\n The Reason Code is :\t" + ex.reasonCode );
ex.printStackTrace();
}
catch (FileNotFoundException ex)
{
System.out.println(" : File Error : "+ex.getMessage());
}
// Was it a Java buffer space error?
catch (IOException ex)
{
System.out.println(" : IO Error : "+ex.getMessage());
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void disconnectQ()
{
try
{
qMgr.commit();
Fromqueue.close();
qMgr.disconnect();
}
catch(Exception e)
{
System.out.println("Exception:"+e);
}
}
public static void main(String args[])
{
SegPut sp=new SegPut();
sp.sendMsg();
sp.disconnectQ();
}
}
if anyone have the solution ,please revert me back.
Waiting for the reply.
Thanks & Regards,
Manoj |
|
Back to top |
|
 |
EddieA |
Posted: Wed Feb 23, 2005 10:11 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
outMsg.offset = 1024; |
Why
Try removing this line, as it's not relevent for what you are trying to do.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
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
|
|
|
|