activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugeny N Dzhurinsky <b...@redwerk.com>
Subject Re: Broker upload url is null?
Date Thu, 07 Aug 2008 11:55:43 GMT
On Thu, Aug 07, 2008 at 01:15:51PM +0200, Marco Buss wrote:
> Is the Blob successfuly uploaded? Can you see it in the jetty file system?

No, the blob isn't uploaded at all. Moreover, I added the code listed below:

===============================================================================
   private BlobTransferPolicy getTransferPolicy() {
        BlobTransferPolicy policy = new BlobTransferPolicy();
        policy.setUploadStrategy(new DefaultBlobUploadStrategy(policy) {

            @Override
            public void deleteFile(ActiveMQBlobMessage message)
                    throws IOException, JMSException {
                System.err.println("Removing file");
                super.deleteFile(message);
            }

            @Override
            public URL uploadFile(ActiveMQBlobMessage message, File file)
                    throws JMSException, IOException {
                System.err.println("Uploading file");
                return super.uploadFile(message, file);
            }

            @Override
            public URL uploadStream(ActiveMQBlobMessage arg0, InputStream arg1)
                    throws JMSException, IOException {
                System.err.println("Uploading stream");
                return super.uploadStream(arg0, arg1);
            }

        });
        return policy;
    }

....

    public void run() {
        final ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(
                "tcp://localhost:1235");
        final BlobTransferPolicy policy = getTransferPolicy();
        factory.setBlobTransferPolicy(policy);
        try {
            final ActiveMQConnection connection = (ActiveMQConnection) factory
                    .createConnection();
            System.out.println("Using upload url = "
                    + policy.getDefaultUploadUrl());
            connection.setBlobTransferPolicy(policy);
            connection.start();
            final ActiveMQSession session = (ActiveMQSession) connection
                    .createSession(false, Session.CLIENT_ACKNOWLEDGE);
            session.setBlobTransferPolicy(policy);
            final Destination destination = session
                    .createQueue(ImageProcessorInterface.srcImgQueueName);
            final Destination tempDestination = session.createTemporaryQueue();
            final MessageProducer producer = session
                    .createProducer(destination);
            final MessageConsumer responseConsumer = session
                    .createConsumer(tempDestination);
            responseConsumer.setMessageListener(new MessageListener() {
            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
            for (int i = 0; i < MESSAGES_NUMBER; i++) {
                InputStream data = ImageProducer.class
                        .getResourceAsStream("/sample_image.jpg");
                System.out.println("Data stream is " + data);
                final BlobMessage message = session.createBlobMessage(data);
                message.setJMSReplyTo(tempDestination);
                message.setJMSCorrelationID(generateMsgId());
                producer.send(message);
                Thread.sleep(SLEEP_TIME);
            }
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
        System.out.println("Done");
    }
===============================================================================

to inject a custom BlobTransferPolicy into ActiveMQConnectionFactory,
ActiveMQConnection and ActiveMQSession instances - but as far as I can see,
there's noting about an attempt to upload the file in logs. At this point I'm
stuck :)

-- 
Eugene N Dzhurinsky

Mime
View raw message