Allright, I was able to resolve the issue - looks like setChunkedStreamingMode
in JDK 1.6 is either broken, or Jetty can't understand it well.

I had created the custom uploading strategy, which is using Commons HttpClient
3.1, and things are working fine. Just in case if somebody will find this
useful - I've attached a class I had created.

Thank you all for your patience :)

================================================================================
package org.apache.activemq.blob;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import javax.jms.JMSException;

import org.apache.activemq.blob.BlobTransferPolicy;
import org.apache.activemq.blob.BlobUploadStrategy;
import org.apache.activemq.blob.DefaultBlobUploadStrategy;
import org.apache.activemq.command.ActiveMQBlobMessage;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PutMethod;

/**
 * Handles the uploading strategy using HttpClient
 */
public class HCBlobUploadStrategy extends DefaultBlobUploadStrategy implements
        BlobUploadStrategy {

    private final HttpClient client;

    public HCBlobUploadStrategy(BlobTransferPolicy transferPolicy) {
        super(transferPolicy);
        client = new HttpClient();
    }

    /**
     * @see 
org.apache.activemq.blob.BlobUploadStrategy#uploadFile(org.apache.activemq.command.ActiveMQBlobMessage,
 java.io.File)
     */
    public URL uploadFile(ActiveMQBlobMessage msg, File file)
            throws JMSException, IOException {
        InputStream stream = new FileInputStream(file);
        URL url = null;
        try {
            url = uploadStream(msg, stream);
        } finally {
            stream.close();
        }
        return url;
    }

    /**
     * @see 
org.apache.activemq.blob.BlobUploadStrategy#uploadStream(org.apache.activemq.command.ActiveMQBlobMessage,
 java.io.InputStream)
     */
    public URL uploadStream(ActiveMQBlobMessage msg, InputStream stream)
            throws JMSException, IOException {
        final URL fileURL = createUploadURL(msg);
        PutMethod put = null;
        try {
            put = new PutMethod(fileURL.toString());
            put.setContentChunked(true);
            put.setRequestEntity(new InputStreamRequestEntity(stream));
            client.executeMethod(put);
        } finally {
            if (put != null)
                put.releaseConnection();
        }
        return fileURL;
    }

}
================================================================================

-- 
Eugene N Dzhurinsky

Attachment: pgpj5Z6ItVCdZ.pgp
Description: PGP signature

Reply via email to