You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by balderman <ba...@gmail.com> on 2008/06/04 13:26:32 UTC

BlobMessage - How to make it work?

Hi
I am using ActiveMQ 5.1.
I want to to use BlobMessage in order to send large amounts of data.
When the consumer get the message  and the below code is executed:
                 inputStream = blobMessage.getInputStream();
the inputStream is null.
I have seen few posts regarding this issue but I could not understand what
is the right way to do it.
More info:
1) The message sender and the message consumer run on my PC.
2) The message broker run on a different machine.
3) I am using Spring JMS template. Here is a config snippet of the Sender:
(I replaced some part of the IP with xyz - but this is the IP of the message
broker)
...
  <bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL">
         
<value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
        </property>
      </bean>
    </property>
  </bean>
...
4) Here is how I create the BlobMessage:
blobMessage = activeMQSession.createBlobMessage(new File("path to the local
file system here"));
When I call blobMessage.getURL() I get null.
If I create the message with a URL as argument:
blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
the call to getURL() return a valid value. 
5) I know there is an option to use BlobTransferPolicy. Do I have to use it
or the default is good enough?
Please advice.

Thanks

Avishay
-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17644495.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: BlobMessage - How to make it work?

Posted by balderman <ba...@gmail.com>.
Hi
Since I need to cross a firewall I use http and not tcp.
Can you make it work with http transport?
I will attach my activemq.xml later.
Thanks
Avishay

Marco Buss wrote:
> 
> Did you change the activemq.xml?
> 
> I only change the uri to get you're code to work. With an unchanged
> activemq.xml and the uri
> tcp://localhost:61616?jms.blobTransferPolicy.defaultUploadUrl=http://localhost:8161/fileserver/ 
> all works fine.
> I have changed the transport from http to tcp and the ports. The included
> webserver (jetty) runs on an other port then the broker.
> 
> 
> balderman wrote:
>> 
>> Here is my "Sender" unit test:
>> 
>> 
>> 
>> 
>> import java.io.File;
>> 
>> import javax.jms.Connection;
>> import javax.jms.Queue;
>> import javax.jms.QueueSender;
>> import javax.jms.Session;
>> 
>> import org.apache.activemq.ActiveMQConnectionFactory;
>> import org.apache.activemq.ActiveMQSession;
>> import org.apache.activemq.BlobMessage;
>> import org.apache.activemq.command.ActiveMQQueue;
>> 
>> public class BlobSender {
>> 
>>     private static final String URI =
>> "http://zyz.16.233.50:61618?jms.blobTransferPolicy.defaultUploadUrl=http://zyz.16.233.50:61618/fileserver/";
>>     
>> 	/**
>> 	 * @param args
>> 	 */
>> 	public static void main(String[] args) throws Exception {
>>         ActiveMQConnectionFactory factory = new
>> ActiveMQConnectionFactory(URI);
>>         factory.setCopyMessageOnSend(false);
>>         Connection  connection  = factory.createQueueConnection();
>>         ActiveMQSession session =
>> (ActiveMQSession)connection.createSession(false,
>> Session.AUTO_ACKNOWLEDGE);        
>>         Queue queue = new ActiveMQQueue("MyQ");
>>         QueueSender queueSender = session.createSender(queue); 
>>         BlobMessage msg = session.createBlobMessage(new
>> File("c:\\zz.txt"));
>>         queueSender.send(msg);
>>         System.out.println("msg was sent.");
>> 
>> 	}
>> 
>> }
>> 
>> Exception is thrown:
>> 
>> Exception in thread "main" javax.jms.JMSException: PUT was not
>> successful: 405 HTTP method PUT is not supported by this URL
>>         at
>> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
>>         at
>> org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:166)
>>         at
>> org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1622)
>>         at
>> org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
>>         at
>> org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241)
>>         at com.bmc.disco.jms.poc.BlobSender.main(BlobSender.java:30)
>> Caused by: java.io.IOException: PUT was not successful: 405 HTTP method
>> PUT is not supported by this URL
>>         at
>> org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadStream(DefaultBlobUploadStrategy.java:70)
>>         at
>> org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadFile(DefaultBlobUploadStrategy.java:44)
>>         at
>> org.apache.activemq.blob.BlobUploader.upload(BlobUploader.java:51)
>>         at
>> org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:163)
>> 
>> 
>> 
>> 
>> 
>> balderman wrote:
>>> 
>>> Hi
>>> I do not think the file is uploaded.:-(
>>> Where should I look for it?
>>> Here:  <ActiveMQ>\webapps\fileserver ?
>>> Is the original file name is kept?
>>> 
>>> Thanks
>>> 
>>> Avishay
>>> 
>>> 
>>> Marco Buss wrote:
>>>> 
>>>> Hello,
>>>> 
>>>> check if the blob is uploaded to the fileserver webapp. If the blob is
>>>> uploaded try this:
>>>> 
>>>> <bean id="jmsFactory"
>>>> class="org.apache.activemq.pool.PooledConnectionFactory"
>>>> destroy-method="stop">
>>>>     <property name="connectionFactory">
>>>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>>>         <property name="brokerURL">
>>>>          
>>>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>>>         </property>
>>>> <!-- default is true -->
>>>>         <property name="copyMessagesOnSend">
>>>> <!-- I am not sure if this works for boolean properties. If not search
>>>> the spring documentation how to inject booleans -->
>>>>           <value>false</value>
>>>>         </property>
>>>>       </bean>
>>>>     </property>
>>>>   </bean>
>>>> 
>>>> If this not work. Please provide a unit test for the problem.
>>>> 
>>>> regards
>>>> Marco Buss
>>>> 
>>>> 
>>>> balderman wrote:
>>>>> 
>>>>> Hi
>>>>> I am using ActiveMQ 5.1.
>>>>> I want to to use BlobMessage in order to send large amounts of data.
>>>>> When the consumer get the message  and the below code is executed:
>>>>>                  inputStream = blobMessage.getInputStream();
>>>>> the inputStream is null.
>>>>> I have seen few posts regarding this issue but I could not understand
>>>>> what is the right way to do it.
>>>>> More info:
>>>>> 1) The message sender and the message consumer run on my PC.
>>>>> 2) The message broker run on a different machine.
>>>>> 3) I am using Spring JMS template. Here is a config snippet of the
>>>>> Sender:
>>>>> (I replaced some part of the IP with xyz - but this is the IP of the
>>>>> message broker)
>>>>> ...
>>>>>   <bean id="jmsFactory"
>>>>> class="org.apache.activemq.pool.PooledConnectionFactory"
>>>>> destroy-method="stop">
>>>>>     <property name="connectionFactory">
>>>>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>>>>         <property name="brokerURL">
>>>>>          
>>>>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>>>>         </property>
>>>>>       </bean>
>>>>>     </property>
>>>>>   </bean>
>>>>> ...
>>>>> 4) Here is how I create the BlobMessage:
>>>>> blobMessage = activeMQSession.createBlobMessage(new File("path to the
>>>>> local file system here"));
>>>>> When I call blobMessage.getURL() I get null.
>>>>> If I create the message with a URL as argument:
>>>>> blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
>>>>> the call to getURL() return a valid value. 
>>>>> 5) I know there is an option to use BlobTransferPolicy. Do I have to
>>>>> use it or the default is good enough?
>>>>> Please advice.
>>>>> 
>>>>> Thanks
>>>>> 
>>>>> Avishay
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17655386.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: BlobMessage - How to make it work?

Posted by Marco Buss <ma...@gmx.de>.
Did you change the activemq.xml?

I only change the uri to get you're code to work. With an unchanged
activemq.xml and the uri
tcp://localhost:61616?jms.blobTransferPolicy.defaultUploadUrl=http://localhost:8161/fileserver/ 
all works fine.
I have changed the transport from http to tcp and the ports. The included
webserver (jetty) runs on an other port then the broker.


balderman wrote:
> 
> Here is my "Sender" unit test:
> 
> 
> 
> 
> import java.io.File;
> 
> import javax.jms.Connection;
> import javax.jms.Queue;
> import javax.jms.QueueSender;
> import javax.jms.Session;
> 
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.activemq.ActiveMQSession;
> import org.apache.activemq.BlobMessage;
> import org.apache.activemq.command.ActiveMQQueue;
> 
> public class BlobSender {
> 
>     private static final String URI =
> "http://zyz.16.233.50:61618?jms.blobTransferPolicy.defaultUploadUrl=http://zyz.16.233.50:61618/fileserver/";
>     
> 	/**
> 	 * @param args
> 	 */
> 	public static void main(String[] args) throws Exception {
>         ActiveMQConnectionFactory factory = new
> ActiveMQConnectionFactory(URI);
>         factory.setCopyMessageOnSend(false);
>         Connection  connection  = factory.createQueueConnection();
>         ActiveMQSession session =
> (ActiveMQSession)connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);        
>         Queue queue = new ActiveMQQueue("MyQ");
>         QueueSender queueSender = session.createSender(queue); 
>         BlobMessage msg = session.createBlobMessage(new
> File("c:\\zz.txt"));
>         queueSender.send(msg);
>         System.out.println("msg was sent.");
> 
> 	}
> 
> }
> 
> Exception is thrown:
> 
> Exception in thread "main" javax.jms.JMSException: PUT was not successful:
> 405 HTTP method PUT is not supported by this URL
>         at
> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
>         at
> org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:166)
>         at
> org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1622)
>         at
> org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
>         at
> org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241)
>         at com.bmc.disco.jms.poc.BlobSender.main(BlobSender.java:30)
> Caused by: java.io.IOException: PUT was not successful: 405 HTTP method
> PUT is not supported by this URL
>         at
> org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadStream(DefaultBlobUploadStrategy.java:70)
>         at
> org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadFile(DefaultBlobUploadStrategy.java:44)
>         at
> org.apache.activemq.blob.BlobUploader.upload(BlobUploader.java:51)
>         at
> org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:163)
> 
> 
> 
> 
> 
> balderman wrote:
>> 
>> Hi
>> I do not think the file is uploaded.:-(
>> Where should I look for it?
>> Here:  <ActiveMQ>\webapps\fileserver ?
>> Is the original file name is kept?
>> 
>> Thanks
>> 
>> Avishay
>> 
>> 
>> Marco Buss wrote:
>>> 
>>> Hello,
>>> 
>>> check if the blob is uploaded to the fileserver webapp. If the blob is
>>> uploaded try this:
>>> 
>>> <bean id="jmsFactory"
>>> class="org.apache.activemq.pool.PooledConnectionFactory"
>>> destroy-method="stop">
>>>     <property name="connectionFactory">
>>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>>         <property name="brokerURL">
>>>          
>>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>>         </property>
>>> <!-- default is true -->
>>>         <property name="copyMessagesOnSend">
>>> <!-- I am not sure if this works for boolean properties. If not search
>>> the spring documentation how to inject booleans -->
>>>           <value>false</value>
>>>         </property>
>>>       </bean>
>>>     </property>
>>>   </bean>
>>> 
>>> If this not work. Please provide a unit test for the problem.
>>> 
>>> regards
>>> Marco Buss
>>> 
>>> 
>>> balderman wrote:
>>>> 
>>>> Hi
>>>> I am using ActiveMQ 5.1.
>>>> I want to to use BlobMessage in order to send large amounts of data.
>>>> When the consumer get the message  and the below code is executed:
>>>>                  inputStream = blobMessage.getInputStream();
>>>> the inputStream is null.
>>>> I have seen few posts regarding this issue but I could not understand
>>>> what is the right way to do it.
>>>> More info:
>>>> 1) The message sender and the message consumer run on my PC.
>>>> 2) The message broker run on a different machine.
>>>> 3) I am using Spring JMS template. Here is a config snippet of the
>>>> Sender:
>>>> (I replaced some part of the IP with xyz - but this is the IP of the
>>>> message broker)
>>>> ...
>>>>   <bean id="jmsFactory"
>>>> class="org.apache.activemq.pool.PooledConnectionFactory"
>>>> destroy-method="stop">
>>>>     <property name="connectionFactory">
>>>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>>>         <property name="brokerURL">
>>>>          
>>>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>>>         </property>
>>>>       </bean>
>>>>     </property>
>>>>   </bean>
>>>> ...
>>>> 4) Here is how I create the BlobMessage:
>>>> blobMessage = activeMQSession.createBlobMessage(new File("path to the
>>>> local file system here"));
>>>> When I call blobMessage.getURL() I get null.
>>>> If I create the message with a URL as argument:
>>>> blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
>>>> the call to getURL() return a valid value. 
>>>> 5) I know there is an option to use BlobTransferPolicy. Do I have to
>>>> use it or the default is good enough?
>>>> Please advice.
>>>> 
>>>> Thanks
>>>> 
>>>> Avishay
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17655237.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: BlobMessage - How to make it work?

Posted by balderman <ba...@gmail.com>.
Here is my "Sender" unit test:




import java.io.File;

import javax.jms.Connection;
import javax.jms.Queue;
import javax.jms.QueueSender;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQSession;
import org.apache.activemq.BlobMessage;
import org.apache.activemq.command.ActiveMQQueue;

public class BlobSender {

    private static final String URI =
"http://zyz.16.233.50:61618?jms.blobTransferPolicy.defaultUploadUrl=http://zyz.16.233.50:61618/fileserver/";
    
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
        ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory(URI);
        factory.setCopyMessageOnSend(false);
        Connection  connection  = factory.createQueueConnection();
        ActiveMQSession session =
(ActiveMQSession)connection.createSession(false, Session.AUTO_ACKNOWLEDGE);        
        Queue queue = new ActiveMQQueue("MyQ");
        QueueSender queueSender = session.createSender(queue); 
        BlobMessage msg = session.createBlobMessage(new File("c:\\zz.txt"));
        queueSender.send(msg);
        System.out.println("msg was sent.");

	}

}

Exception is thrown:

Exception in thread "main" javax.jms.JMSException: PUT was not successful:
405 HTTP method PUT is not supported by this URL
        at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
        at
org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:166)
        at
org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1622)
        at
org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
        at
org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241)
        at com.bmc.disco.jms.poc.BlobSender.main(BlobSender.java:30)
Caused by: java.io.IOException: PUT was not successful: 405 HTTP method PUT
is not supported by this URL
        at
org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadStream(DefaultBlobUploadStrategy.java:70)
        at
org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadFile(DefaultBlobUploadStrategy.java:44)
        at
org.apache.activemq.blob.BlobUploader.upload(BlobUploader.java:51)
        at
org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:163)





balderman wrote:
> 
> Hi
> I do not think the file is uploaded.:-(
> Where should I look for it?
> Here:  <ActiveMQ>\webapps\fileserver ?
> Is the original file name is kept?
> 
> Thanks
> 
> Avishay
> 
> 
> Marco Buss wrote:
>> 
>> Hello,
>> 
>> check if the blob is uploaded to the fileserver webapp. If the blob is
>> uploaded try this:
>> 
>> <bean id="jmsFactory"
>> class="org.apache.activemq.pool.PooledConnectionFactory"
>> destroy-method="stop">
>>     <property name="connectionFactory">
>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>         <property name="brokerURL">
>>          
>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>         </property>
>> <!-- default is true -->
>>         <property name="copyMessagesOnSend">
>> <!-- I am not sure if this works for boolean properties. If not search
>> the spring documentation how to inject booleans -->
>>           <value>false</value>
>>         </property>
>>       </bean>
>>     </property>
>>   </bean>
>> 
>> If this not work. Please provide a unit test for the problem.
>> 
>> regards
>> Marco Buss
>> 
>> 
>> balderman wrote:
>>> 
>>> Hi
>>> I am using ActiveMQ 5.1.
>>> I want to to use BlobMessage in order to send large amounts of data.
>>> When the consumer get the message  and the below code is executed:
>>>                  inputStream = blobMessage.getInputStream();
>>> the inputStream is null.
>>> I have seen few posts regarding this issue but I could not understand
>>> what is the right way to do it.
>>> More info:
>>> 1) The message sender and the message consumer run on my PC.
>>> 2) The message broker run on a different machine.
>>> 3) I am using Spring JMS template. Here is a config snippet of the
>>> Sender:
>>> (I replaced some part of the IP with xyz - but this is the IP of the
>>> message broker)
>>> ...
>>>   <bean id="jmsFactory"
>>> class="org.apache.activemq.pool.PooledConnectionFactory"
>>> destroy-method="stop">
>>>     <property name="connectionFactory">
>>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>>         <property name="brokerURL">
>>>          
>>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>>         </property>
>>>       </bean>
>>>     </property>
>>>   </bean>
>>> ...
>>> 4) Here is how I create the BlobMessage:
>>> blobMessage = activeMQSession.createBlobMessage(new File("path to the
>>> local file system here"));
>>> When I call blobMessage.getURL() I get null.
>>> If I create the message with a URL as argument:
>>> blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
>>> the call to getURL() return a valid value. 
>>> 5) I know there is an option to use BlobTransferPolicy. Do I have to use
>>> it or the default is good enough?
>>> Please advice.
>>> 
>>> Thanks
>>> 
>>> Avishay
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17646660.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: BlobMessage - How to make it work?

Posted by balderman <ba...@gmail.com>.
Hi
I do not think the file is uploaded.:-(
Where should I look for it?
Here:  <ActiveMQ>\webapps\fileserver ?
Is the original file name is kept?

Thanks

Avishay


Marco Buss wrote:
> 
> Hello,
> 
> check if the blob is uploaded to the fileserver webapp. If the blob is
> uploaded try this:
> 
> <bean id="jmsFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory"
> destroy-method="stop">
>     <property name="connectionFactory">
>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>         <property name="brokerURL">
>          
> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>         </property>
> <!-- default is true -->
>         <property name="copyMessagesOnSend">
> <!-- I am not sure if this works for boolean properties. If not search the
> spring documentation how to inject booleans -->
>           <value>false</value>
>         </property>
>       </bean>
>     </property>
>   </bean>
> 
> If this not work. Please provide a unit test for the problem.
> 
> regards
> Marco Buss
> 
> 
> balderman wrote:
>> 
>> Hi
>> I am using ActiveMQ 5.1.
>> I want to to use BlobMessage in order to send large amounts of data.
>> When the consumer get the message  and the below code is executed:
>>                  inputStream = blobMessage.getInputStream();
>> the inputStream is null.
>> I have seen few posts regarding this issue but I could not understand
>> what is the right way to do it.
>> More info:
>> 1) The message sender and the message consumer run on my PC.
>> 2) The message broker run on a different machine.
>> 3) I am using Spring JMS template. Here is a config snippet of the
>> Sender:
>> (I replaced some part of the IP with xyz - but this is the IP of the
>> message broker)
>> ...
>>   <bean id="jmsFactory"
>> class="org.apache.activemq.pool.PooledConnectionFactory"
>> destroy-method="stop">
>>     <property name="connectionFactory">
>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>         <property name="brokerURL">
>>          
>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>         </property>
>>       </bean>
>>     </property>
>>   </bean>
>> ...
>> 4) Here is how I create the BlobMessage:
>> blobMessage = activeMQSession.createBlobMessage(new File("path to the
>> local file system here"));
>> When I call blobMessage.getURL() I get null.
>> If I create the message with a URL as argument:
>> blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
>> the call to getURL() return a valid value. 
>> 5) I know there is an option to use BlobTransferPolicy. Do I have to use
>> it or the default is good enough?
>> Please advice.
>> 
>> Thanks
>> 
>> Avishay
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17645544.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: BlobMessage - How to make it work?

Posted by Marco Buss <ma...@gmx.de>.
I have this also fixed in my improvment
https://issues.apache.org/activemq/browse/AMQ-1744 :D


ttmdev wrote:
> 
> You should make a note of the following JIRA
> 
> https://issues.apache.org/activemq/browse/AMQ-1529
> 
> As it currently stands, BLOBs are not deleted from the web server's
> repository. 
> 
> Joe
> 
> 
> ttmdev wrote:
>> 
>> I have opened up a JIRA for this and submitted a patch for review. 
>> 
>> https://issues.apache.org/activemq/browse/AMQ-1770
>> 
>> Joe
>> 
>> 
>> Marco Buss wrote:
>>> 
>>> Hello,
>>> 
>>> check if the blob is uploaded to the fileserver webapp. If the blob is
>>> uploaded try this:
>>> 
>>> <bean id="jmsFactory"
>>> class="org.apache.activemq.pool.PooledConnectionFactory"
>>> destroy-method="stop">
>>>     <property name="connectionFactory">
>>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>>         <property name="brokerURL">
>>>          
>>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>>         </property>
>>> <!-- default is true -->
>>>         <property name="copyMessageOnSend">
>>> <!-- I am not sure if this works for boolean properties. If not search
>>> the spring documentation how to inject booleans -->
>>>           <value>false</value>
>>>         </property>
>>>       </bean>
>>>     </property>
>>>   </bean>
>>> 
>>> If this not work. Please provide a unit test for the problem.
>>> 
>>> regards
>>> Marco Buss
>>> 
>>> 
>>> balderman wrote:
>>>> 
>>>> Hi
>>>> I am using ActiveMQ 5.1.
>>>> I want to to use BlobMessage in order to send large amounts of data.
>>>> When the consumer get the message  and the below code is executed:
>>>>                  inputStream = blobMessage.getInputStream();
>>>> the inputStream is null.
>>>> I have seen few posts regarding this issue but I could not understand
>>>> what is the right way to do it.
>>>> More info:
>>>> 1) The message sender and the message consumer run on my PC.
>>>> 2) The message broker run on a different machine.
>>>> 3) I am using Spring JMS template. Here is a config snippet of the
>>>> Sender:
>>>> (I replaced some part of the IP with xyz - but this is the IP of the
>>>> message broker)
>>>> ...
>>>>   <bean id="jmsFactory"
>>>> class="org.apache.activemq.pool.PooledConnectionFactory"
>>>> destroy-method="stop">
>>>>     <property name="connectionFactory">
>>>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>>>         <property name="brokerURL">
>>>>          
>>>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>>>         </property>
>>>>       </bean>
>>>>     </property>
>>>>   </bean>
>>>> ...
>>>> 4) Here is how I create the BlobMessage:
>>>> blobMessage = activeMQSession.createBlobMessage(new File("path to the
>>>> local file system here"));
>>>> When I call blobMessage.getURL() I get null.
>>>> If I create the message with a URL as argument:
>>>> blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
>>>> the call to getURL() return a valid value. 
>>>> 5) I know there is an option to use BlobTransferPolicy. Do I have to
>>>> use it or the default is good enough?
>>>> Please advice.
>>>> 
>>>> Thanks
>>>> 
>>>> Avishay
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17674184.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: BlobMessage - How to make it work?

Posted by ttmdev <jo...@ttmsolutions.com>.
You should make a note of the following JIRA

https://issues.apache.org/activemq/browse/AMQ-1529

As it currently stands, BLOBs are not deleted from the web server's
repository. 

Joe


ttmdev wrote:
> 
> I have opened up a JIRA for this and submitted a patch for review. 
> 
> https://issues.apache.org/activemq/browse/AMQ-1770
> 
> Joe
> 
> 
> Marco Buss wrote:
>> 
>> Hello,
>> 
>> check if the blob is uploaded to the fileserver webapp. If the blob is
>> uploaded try this:
>> 
>> <bean id="jmsFactory"
>> class="org.apache.activemq.pool.PooledConnectionFactory"
>> destroy-method="stop">
>>     <property name="connectionFactory">
>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>         <property name="brokerURL">
>>          
>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>         </property>
>> <!-- default is true -->
>>         <property name="copyMessageOnSend">
>> <!-- I am not sure if this works for boolean properties. If not search
>> the spring documentation how to inject booleans -->
>>           <value>false</value>
>>         </property>
>>       </bean>
>>     </property>
>>   </bean>
>> 
>> If this not work. Please provide a unit test for the problem.
>> 
>> regards
>> Marco Buss
>> 
>> 
>> balderman wrote:
>>> 
>>> Hi
>>> I am using ActiveMQ 5.1.
>>> I want to to use BlobMessage in order to send large amounts of data.
>>> When the consumer get the message  and the below code is executed:
>>>                  inputStream = blobMessage.getInputStream();
>>> the inputStream is null.
>>> I have seen few posts regarding this issue but I could not understand
>>> what is the right way to do it.
>>> More info:
>>> 1) The message sender and the message consumer run on my PC.
>>> 2) The message broker run on a different machine.
>>> 3) I am using Spring JMS template. Here is a config snippet of the
>>> Sender:
>>> (I replaced some part of the IP with xyz - but this is the IP of the
>>> message broker)
>>> ...
>>>   <bean id="jmsFactory"
>>> class="org.apache.activemq.pool.PooledConnectionFactory"
>>> destroy-method="stop">
>>>     <property name="connectionFactory">
>>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>>         <property name="brokerURL">
>>>          
>>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>>         </property>
>>>       </bean>
>>>     </property>
>>>   </bean>
>>> ...
>>> 4) Here is how I create the BlobMessage:
>>> blobMessage = activeMQSession.createBlobMessage(new File("path to the
>>> local file system here"));
>>> When I call blobMessage.getURL() I get null.
>>> If I create the message with a URL as argument:
>>> blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
>>> the call to getURL() return a valid value. 
>>> 5) I know there is an option to use BlobTransferPolicy. Do I have to use
>>> it or the default is good enough?
>>> Please advice.
>>> 
>>> Thanks
>>> 
>>> Avishay
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17672886.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: BlobMessage - How to make it work?

Posted by ttmdev <jo...@ttmsolutions.com>.
I have opened up a JIRA for this and submitted a patch for review. 

https://issues.apache.org/activemq/browse/AMQ-1770

Joe


Marco Buss wrote:
> 
> Hello,
> 
> check if the blob is uploaded to the fileserver webapp. If the blob is
> uploaded try this:
> 
> <bean id="jmsFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory"
> destroy-method="stop">
>     <property name="connectionFactory">
>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>         <property name="brokerURL">
>          
> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>         </property>
> <!-- default is true -->
>         <property name="copyMessageOnSend">
> <!-- I am not sure if this works for boolean properties. If not search the
> spring documentation how to inject booleans -->
>           <value>false</value>
>         </property>
>       </bean>
>     </property>
>   </bean>
> 
> If this not work. Please provide a unit test for the problem.
> 
> regards
> Marco Buss
> 
> 
> balderman wrote:
>> 
>> Hi
>> I am using ActiveMQ 5.1.
>> I want to to use BlobMessage in order to send large amounts of data.
>> When the consumer get the message  and the below code is executed:
>>                  inputStream = blobMessage.getInputStream();
>> the inputStream is null.
>> I have seen few posts regarding this issue but I could not understand
>> what is the right way to do it.
>> More info:
>> 1) The message sender and the message consumer run on my PC.
>> 2) The message broker run on a different machine.
>> 3) I am using Spring JMS template. Here is a config snippet of the
>> Sender:
>> (I replaced some part of the IP with xyz - but this is the IP of the
>> message broker)
>> ...
>>   <bean id="jmsFactory"
>> class="org.apache.activemq.pool.PooledConnectionFactory"
>> destroy-method="stop">
>>     <property name="connectionFactory">
>>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>>         <property name="brokerURL">
>>          
>> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>>         </property>
>>       </bean>
>>     </property>
>>   </bean>
>> ...
>> 4) Here is how I create the BlobMessage:
>> blobMessage = activeMQSession.createBlobMessage(new File("path to the
>> local file system here"));
>> When I call blobMessage.getURL() I get null.
>> If I create the message with a URL as argument:
>> blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
>> the call to getURL() return a valid value. 
>> 5) I know there is an option to use BlobTransferPolicy. Do I have to use
>> it or the default is good enough?
>> Please advice.
>> 
>> Thanks
>> 
>> Avishay
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17671420.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: BlobMessage - How to make it work?

Posted by Marco Buss <ma...@gmx.de>.
Hello,

check if the blob is uploaded to the fileserver webapp. If the blob is
uploaded try this:

<bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL">
         
<value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
        </property>
<!-- default is true -->
        <property name="copyMessagesOnSend">
<!-- I am not sure if this works for boolean properties. If not search the
spring documentation how to inject booleans -->
          <value>false</value>
        </property>
      </bean>
    </property>
  </bean>

If this not work. Please provide a unit test for the problem.

regards
Marco Buss


balderman wrote:
> 
> Hi
> I am using ActiveMQ 5.1.
> I want to to use BlobMessage in order to send large amounts of data.
> When the consumer get the message  and the below code is executed:
>                  inputStream = blobMessage.getInputStream();
> the inputStream is null.
> I have seen few posts regarding this issue but I could not understand what
> is the right way to do it.
> More info:
> 1) The message sender and the message consumer run on my PC.
> 2) The message broker run on a different machine.
> 3) I am using Spring JMS template. Here is a config snippet of the Sender:
> (I replaced some part of the IP with xyz - but this is the IP of the
> message broker)
> ...
>   <bean id="jmsFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory"
> destroy-method="stop">
>     <property name="connectionFactory">
>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>         <property name="brokerURL">
>          
> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>         </property>
>       </bean>
>     </property>
>   </bean>
> ...
> 4) Here is how I create the BlobMessage:
> blobMessage = activeMQSession.createBlobMessage(new File("path to the
> local file system here"));
> When I call blobMessage.getURL() I get null.
> If I create the message with a URL as argument:
> blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
> the call to getURL() return a valid value. 
> 5) I know there is an option to use BlobTransferPolicy. Do I have to use
> it or the default is good enough?
> Please advice.
> 
> Thanks
> 
> Avishay
> 

-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17645127.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: BlobMessage - How to make it work?

Posted by balderman <ba...@gmail.com>.
More info:
~~~~~~~
Digging into the source I found this test class:
org.apache.activemq.blob.DefaultBlobUploadStrategyTest
The code below show that the message is not sent via message.send() call. 
It is uploaded.
Should I add this part to my code:         strategy.uploadFile(msg, file); ?
As far as I understand I don't have to make an explicit call for this..
It should be handled by the msg.send() call - isn't it?

...
  public void xtestUploadViaDefaultBlobUploadStrategy() throws Exception {
        // 0. Initialise
        File file = File.createTempFile("amq-data-file-", ".dat");
        // lets write some data
        BufferedWriter writer = new BufferedWriter(new FileWriter(file));
        writer.append("Hello World!");
        writer.close();

        ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory(URI);
        BlobTransferPolicy policy = factory.getBlobTransferPolicy();

        ActiveMQBlobMessage msg = new ActiveMQBlobMessage();
        msg.setMessageId(new MessageId());

        // 1. Upload
        DefaultBlobUploadStrategy strategy = new
DefaultBlobUploadStrategy(policy);
        strategy.uploadFile(msg, file);

        // 2. Download
        msg.setURL(new URL(FILESERVER_URL + msg.getMessageId()));

        InputStream in = msg.getInputStream();
        long bytesRead = 0;
        byte[] buffer = new byte[1024 * 1024];

        while (true) {
            int c = in.read(buffer);
            if (c == -1) {
                break;
            }
            bytesRead += c;
        }
        in.close();
        TestCase.assertTrue(bytesRead == file.length());

        // 3. Delete
        strategy.deleteFile(msg);
    }
...

Avishay

balderman wrote:
> 
> Hi
> I am using ActiveMQ 5.1.
> I want to to use BlobMessage in order to send large amounts of data.
> When the consumer get the message  and the below code is executed:
>                  inputStream = blobMessage.getInputStream();
> the inputStream is null.
> I have seen few posts regarding this issue but I could not understand what
> is the right way to do it.
> More info:
> 1) The message sender and the message consumer run on my PC.
> 2) The message broker run on a different machine.
> 3) I am using Spring JMS template. Here is a config snippet of the Sender:
> (I replaced some part of the IP with xyz - but this is the IP of the
> message broker)
> ...
>   <bean id="jmsFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory"
> destroy-method="stop">
>     <property name="connectionFactory">
>       <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>         <property name="brokerURL">
>          
> <value>http://xyz.16.233.50:61618?jms.blobTransferPolicy.uploadUrl=http://xyz.16.233.50:8161/fileserver/</value>
>         </property>
>       </bean>
>     </property>
>   </bean>
> ...
> 4) Here is how I create the BlobMessage:
> blobMessage = activeMQSession.createBlobMessage(new File("path to the
> local file system here"));
> When I call blobMessage.getURL() I get null.
> If I create the message with a URL as argument:
> blobMessage = activeMQSession.createBlobMessage(new URL("url here"));
> the call to getURL() return a valid value. 
> 5) I know there is an option to use BlobTransferPolicy. Do I have to use
> it or the default is good enough?
> Please advice.
> 
> Thanks
> 
> Avishay
> 

-- 
View this message in context: http://www.nabble.com/BlobMessage---How-to-make-it-work--tp17644495s2354p17644989.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.