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 » Faced problem in Segmentation in JAVA

Post new topic  Reply to topic
 Faced problem in Segmentation in JAVA « View previous topic :: View next topic » 
Author Message
manojkpradhan
PostPosted: Wed Feb 23, 2005 1:02 am    Post subject: Faced problem in Segmentation in JAVA Reply with quote

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
View user's profile Send private message
EddieA
PostPosted: Wed Feb 23, 2005 10:11 am    Post subject: Reply with quote

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
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 » Faced problem in Segmentation in JAVA
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.