how do you upload a binary file via MQ client api?

Posted by koendewaele on 03-Jun-2009 06:15

Hi,

We"re developing an MQ client application. Part of the functionality is an upload of a binary file (think PDF, MS-word etc).

The following is a code snippet for sending the file. But I can't get it to work. This snippet is based on the Multpart MQ sample.

Am I missing something here?

t.i.a

public String UploadBinaryFile(String filename) throws JMSException, IOException
{
  
        javax.jms.ConnectionFactory factory;
        factory = new progress.message.jclient.ConnectionFactory (this.BROKER_NAME);
        connect = factory.createConnection (this.BROKER_USER, this.BROKER_PASSWORD);
        session = connect.createSession(false,javax.jms.Session.AUTO_ACKNOWLEDGE);

        javax.jms.Queue queue = session.createQueue (this.MQ_QUEUE);
        sender = session.createProducer(queue);
        connect.start();
        MultipartMessage mm = ((progress.message.jclient.Session)session).createMultipartMessage();
      
        FileDataSource fds = new FileDataSource(filename);
        DataHandler dh = new DataHandler (fds);
        Part filepart = mm.createPart(dh);
        filepart.getHeader().setContentId("FILEDATA");

  
        mm.addPart(filepart);


        sender.send( mm);

   

       return mm.getJMSMessageID().toString();
       
}

All Replies

This thread is closed