activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lou Parisi <Lou.Par...@photomask.com>
Subject BlobMessage
Date Thu, 16 Apr 2009 22:59:34 GMT

I am trying to send a BlobMessage with a file.  I was able to get it to work
with ftp URL. This seems to send the URL and then use FTP to get the file
into the queue where I can then successfully write it out to a directory.

If I try to use an InputStream or File object to create the message I get a
connection refused exception.  I have seen others write about this problem
in the forum but did not see any solution.  I am using the latest 5.2
download for my test.  I am running as a JUnit test just to try it out. The
code for setup and execution along with the stackTrace for each case are
below.  If anyone could help I would appreciate it.  

Does anyone have the BlobMessage working with a File reference to create the
message?

--------
setup:
--------
		broker = new BrokerService();
		broker.setUseJmx(true);
		broker.addConnector("tcp://localhost:61616");
		broker.start();
		ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory();
		connectionFactory.setBrokerURL(BROKER_URL);
		connection = (ActiveMQConnection) connectionFactory.createConnection();
		connection.start();
		session = (ActiveMQSession) connection.createSession(false,
				Session.AUTO_ACKNOWLEDGE);
		destination = session.createQueue(QUEUE_NAME);
		long time = new Date().getTime();
		outFile = new File(OUT_FILE_PATH + time + "." + OUT_FILE_BASENAME);
---------
sendFile:
---------
		//System.out.println("Getting file from " + ftpURLString);
		//BlobMessage msg = session.createBlobMessage(ftpURL);
		System.out.println("Getting file from " + inFile.getAbsolutePath());
		//BlobMessage msg = session.createBlobMessage(inFile);
		InputStream instr = new FileInputStream(inFile);
		BlobMessage msg = session.createBlobMessage(instr);
		MessageProducer producer = session.createProducer(destination);
		System.out.println("Sending message ...");
		producer.send(msg);

		System.out.println("message sent.");

-------------------
StackTrace for File:
-------------------
javax.jms.JMSException: Connection refused: connect
	at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
	at
org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:167)
	at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1637)
	at
org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
	at
org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241)
	at
com.photomask.gate.blobsender.JmsBlobSenderTest.sendFile(JmsBlobSenderTest.java:112)
	at
com.photomask.gate.blobsender.JmsBlobSenderTest.testSendBlob(JmsBlobSenderTest.java:92)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.Socket.connect(Socket.java:519)
	at java.net.Socket.connect(Socket.java:469)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
	at sun.net.www.http.HttpClient.New(HttpClient.java:306)
	at sun.net.www.http.HttpClient.New(HttpClient.java:323)
	at
sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:788)
	at
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:729)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:654)
	at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:832)
	at
org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadStream(DefaultBlobUploadStrategy.java:59)
	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:164)
	... 23 more

---------------------------
StackTrace for InputStream:
---------------------------
javax.jms.JMSException: Connection refused: connect
	at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
	at
org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:167)
	at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1637)
	at
org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
	at
org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241)
	at
com.photomask.gate.blobsender.JmsBlobSenderTest.sendFile(JmsBlobSenderTest.java:115)
	at
com.photomask.gate.blobsender.JmsBlobSenderTest.testSendBlob(JmsBlobSenderTest.java:93)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.Socket.connect(Socket.java:519)
	at java.net.Socket.connect(Socket.java:469)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
	at sun.net.www.http.HttpClient.New(HttpClient.java:306)
	at sun.net.www.http.HttpClient.New(HttpClient.java:323)
	at
sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:788)
	at
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:729)
	at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:654)
	at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:832)
	at
org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadStream(DefaultBlobUploadStrategy.java:59)
	at org.apache.activemq.blob.BlobUploader.upload(BlobUploader.java:53)
	at
org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:164)
	... 23 more


 
-- 
View this message in context: http://www.nabble.com/BlobMessage-tp23088120p23088120.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message