ActiveMQ connection Url for Blob Messages

1.6k views Asked by At

I my application i have a remote ActiveMQ server and embedded ActiveMQ Server. When i send text messages it's working. But when i try to send Blob messages it throws a javax.jms.JMSException caused by java.net.MalformedURLException and java.lang.NumberFormatException.

My Broker URL

String broker1 = "tcp://localhost:7005?jms.blobTransferPolicy.defaultUploadUrl=http://localhost:61617";

where tcp://localhost:7005 is an embedded broker, and http://localhost:61617 is a remote broker.

My Producer code

File file=new File("C:/Users/xxx/Downloads/1234.txt");

ActiveMQConnection connection = ActiveMQConnection.makeConnection(broker);
connection.start();
ActiveMQSession session = (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create the destination (Topic or Queue)
Destination destination = session.createQueue("test");
MessageProducer producer = session.createProducer(destination);

BlobMessage message = session.createBlobMessage(file);
System.out.println("upload started");
producer.send(message);
System.out.println("upload finished");
session.close();
connection.close();
1

There are 1 answers

0
Bruce On

URL should be like this embededbroker?jms.blobTransferPolicy.defaultUploadUrl=externalurl

In case of failure in embedded URL then external URL will be used.By default activemq provides a file server in this link http://(activemq server ip):portnumber/fileserver

For example if your activemq server running on localhost url should be http://localhost:8161/fileserver/ It

It supports HTTP or FTP or SCP or some other point-to-point protocol.