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 » Streaming data from MQMessage object to MF DB2

Post new topic  Reply to topic
 Streaming data from MQMessage object to MF DB2 « View previous topic :: View next topic » 
Author Message
72dolfan
PostPosted: Tue Feb 09, 2010 7:02 am    Post subject: Streaming data from MQMessage object to MF DB2 Reply with quote

Acolyte

Joined: 02 May 2006
Posts: 53

Hi All,

I have a Web App running on Shared WAS 7.0 servers that pulls messages form a queue using Java MQ API and stores the header and message in DB2 on z/OS via a Stored Procedure call. Some of these messages are rather large (36 MB) and have cuased Out Of Memory issues ont he server.

We get the message from the queue into a MQMessage object. We also create a object inmemory called stpBean which holds the MQ Header info and message text. So to get the message into the stpBean, we use the following statement;

stpBean.setMsgString(mqMessage.readStringOfCharLength(mqMessage.getDataLength()));

The stpBean object is passed in the STP to a z/OS program to handle the inserts. To do that, we create a callable statement and set the parameters (parm 39 is the message data).

public void setParameterValues(CallableStatement cs, STPBean stpBean) throws SQLException{
cs.setString(1, stpBean.getCalltype());
cs.setString(2, stpBean.getRetCode());
cs.setString(3, stpBean.getRetMessage());
cs.setBigDecimal(4, stpBean.getSqlCode());
cs.setString(5, stpBean.getUniqueId());
cs.setBigDecimal(6, stpBean.getMsgNumber());
cs.setString(7, stpBean.getQueueName());
cs.setString(8, stpBean.getQueueManagerName());
cs.setString(9, stpBean.getCurrentDate());
cs.setString(10, stpBean.getStrucID());
cs.setBigDecimal(11, stpBean.getStrucVersion());
cs.setBigDecimal(12, stpBean.getReportMsg());
cs.setBigDecimal(13, stpBean.getMessageType());
cs.setBigDecimal(14, stpBean.getMessageExpiryTm());
cs.setBigDecimal(15, stpBean.getFeedback());
cs.setBigDecimal(16,stpBean.getEncoding());
cs.setBigDecimal(17, stpBean.getCharacterSet());
cs.setString(18, stpBean.getFormat());
cs.setBigDecimal(19, stpBean.getPriority());
cs.setBigDecimal(20, stpBean.getPersistence());
cs.setString(21, stpBean.getMessageId());
cs.setString(22, stpBean.getCorrelationId());
cs.setBigDecimal(23, stpBean.getBackoutCount());
cs.setString(24, stpBean.getReplyToQueueName());
cs.setString(25, stpBean.getReplyToQueueManagerName());
cs.setString(26, stpBean.getUserId());
cs.setString(27, stpBean.getAccountingToken());
cs.setString(28, stpBean.getApplicationIdData());
cs.setBigDecimal(29, stpBean.getPutApplicationType());
cs.setString(30, stpBean.getPutApplicationName());
cs.setString(31, stpBean.getPutDate());
cs.setString(32, stpBean.getPutTime());
cs.setString(33, stpBean.getApplicationOriginData());
cs.setString(34, stpBean.getGroupId());
cs.setBigDecimal(35, stpBean.getMessageSequenceNumber());
cs.setBigDecimal(36, stpBean.getMessageOffset());
cs.setBigDecimal(37, stpBean.getMessageFlags());
cs.setBigDecimal(38, stpBean.getOriginalLength());
cs.setObject(39, stpBean.getMsgString().getBytes(), Types.BLOB);

What I'd like to do is eliminate the need to store the large message in the stpBean object and use streaming instead to avoid the need for three chunks of contiguous memory (MQMessage, stpBean, & that created in the setObject(39) above.

I've been looking at ByteArrayOutputStream as a possiblity, but after creating the output stream;

ByteArrayOutputStream os = new ByteArrayOutputStream();

I'm not sure how to write the stream instead of

stpBean.setMsgString(mqMessage.readStringOfCharLength(mqMessage.getDataLength()));

Once that is done, I plan to use setBinaryStream inside the setObject on parameter 39 above, but I'm not certain how to do that either.

Anyone out there know how to write the outputstream and then code the setBinaryStream?

Thanks!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Feb 09, 2010 9:17 pm    Post subject: Reply with quote

Grand High Poobah

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

Many ways to skin a cat in io. This is basics of the io and nio java classes.
Look them up and get a java io tutorial.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
72dolfan
PostPosted: Wed Feb 10, 2010 6:53 am    Post subject: Reply with quote

Acolyte

Joined: 02 May 2006
Posts: 53

Thanks for all your help.
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 » Streaming data from MQMessage object to MF DB2
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.