You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by James Strachan <ja...@gmail.com> on 2006/11/16 10:01:50 UTC
support for FileMessage?
Saw an interesting blog post today...
http://weblogs.java.net/blog/guruwons/archive/2006/11/sending_large_f.html
As I mentioned on the comments, I'd like to extend this a little to
support both out-of-band transfer (e.g. its basically a message with a
URL in it to that the user can download the file from some remote
destination) or the file is actually sent over the JMS network, so it
can act as a facade to the existing JMS Streams feature...
http://incubator.apache.org/activemq/jms-streams.html
So am thinking from a client API perspective they do one of the following...
// send a message out of band...
FileMessage message = session.createRemoteFileMessage(new
URL("http:///foo.com/bar.jpg"));
// send a local file over the JMS network
FileMessage message = session.createLocalFileMessage(new
File("~/myfiles/bar.jpg"));
then for consumers...
if (message instanceof FileMessage) {
FileMessage fileMessage = (FileMessage) message;
InputStream in = fileMessage.getInputStream();
// lets read the file...
// or lets force the file to be manifested as a local file so we can
work directly on the file instead
URL url = fileMessage.getURL();
// we can now open the file as many times as we like...
}
Thoughts?
--
James
-------
http://radio.weblogs.com/0112098/
Re: support for FileMessage?
Posted by Hiram Chirino <hi...@hiramchirino.com>.
On 11/16/06, James Strachan <ja...@gmail.com> wrote:
> On 11/16/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> > Ok.
> >
> > Why does the producer need to decide if the stream is sent out of band or not??
>
I see what you mean now.
> Otherwise how would ActiveMQ know whether or not to send a URL or the
> contents of the file? e.g. ActiveMQ can't really guess if
>
> new URL("file://foo/bar")
>
> needs to be sent out of band or in-band? Only the producer can know if
> the thing its passing to ActiveMQ is a valid in-band or out-of-band
> thing.
>
> It is completely obvious for InputStream that its not out-of-band
> though - am more thinking for URL/File where it may or may not be out
> of band
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
--
Regards,
Hiram
Blog: http://hiramchirino.com
Re: support for FileMessage?
Posted by James Strachan <ja...@gmail.com>.
On 11/16/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> Ok.
>
> Why does the producer need to decide if the stream is sent out of band or not??
Otherwise how would ActiveMQ know whether or not to send a URL or the
contents of the file? e.g. ActiveMQ can't really guess if
new URL("file://foo/bar")
needs to be sent out of band or in-band? Only the producer can know if
the thing its passing to ActiveMQ is a valid in-band or out-of-band
thing.
It is completely obvious for InputStream that its not out-of-band
though - am more thinking for URL/File where it may or may not be out
of band
--
James
-------
http://radio.weblogs.com/0112098/
Re: support for FileMessage?
Posted by Hiram Chirino <hi...@hiramchirino.com>.
Ok.
Why does the producer need to decide if the stream is sent out of band or not??
On 11/16/06, James Strachan <ja...@gmail.com> wrote:
> On 11/16/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> > I like it.. But I wonder if we can do something to handle streams out
> > of band in general. Here's a use case I'm thinking about...
> >
> > A big file is being posted to a servlet and the servlet wants to pass
> > that input stream it's receiving to a JMS consumer somewhere in the
> > back end. So there is no actual file or URL to identify that stream
> > but I want to 'pass' the stream to a consumer using JMS routing/load
> > balancing. And ideally the contents of the stream would be sent out
> > band with respect to the JMS network.
>
> Yeah. Am thinking something like
>
> public class ActiveMQSession {
>
> // send a local file or stream over JMS
> public FileMessage createLocalFileMessage(InputStream inputStream) {...}
> public FileMessage createLocalFileMessage(File file) {..,}
> public FileMessage createLocalFileMessage(URL url) {..,}
>
>
> // send a remote URL over JMS
> public FileMessage createRemoteFileMessage(URL url) {...}
> }
>
> i.e. from a consumers perpective they don't really need to care if its
> in-band or out-of-band transfer of the content, its a decision for the
> producer to decide
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
--
Regards,
Hiram
Blog: http://hiramchirino.com
Re: support for FileMessage?
Posted by James Strachan <ja...@gmail.com>.
On 11/16/06, Hiram Chirino <hi...@hiramchirino.com> wrote:
> I like it.. But I wonder if we can do something to handle streams out
> of band in general. Here's a use case I'm thinking about...
>
> A big file is being posted to a servlet and the servlet wants to pass
> that input stream it's receiving to a JMS consumer somewhere in the
> back end. So there is no actual file or URL to identify that stream
> but I want to 'pass' the stream to a consumer using JMS routing/load
> balancing. And ideally the contents of the stream would be sent out
> band with respect to the JMS network.
Yeah. Am thinking something like
public class ActiveMQSession {
// send a local file or stream over JMS
public FileMessage createLocalFileMessage(InputStream inputStream) {...}
public FileMessage createLocalFileMessage(File file) {..,}
public FileMessage createLocalFileMessage(URL url) {..,}
// send a remote URL over JMS
public FileMessage createRemoteFileMessage(URL url) {...}
}
i.e. from a consumers perpective they don't really need to care if its
in-band or out-of-band transfer of the content, its a decision for the
producer to decide
--
James
-------
http://radio.weblogs.com/0112098/
Re: support for FileMessage?
Posted by Hiram Chirino <hi...@hiramchirino.com>.
I like it.. But I wonder if we can do something to handle streams out
of band in general. Here's a use case I'm thinking about...
A big file is being posted to a servlet and the servlet wants to pass
that input stream it's receiving to a JMS consumer somewhere in the
back end. So there is no actual file or URL to identify that stream
but I want to 'pass' the stream to a consumer using JMS routing/load
balancing. And ideally the contents of the stream would be sent out
band with respect to the JMS network.
It seems to me that if we can handle a case like that, transmitting
URL or File based resources is just a simple case of the above.
Regards,
Hiram
On 11/16/06, James Strachan <ja...@gmail.com> wrote:
> Saw an interesting blog post today...
>
> http://weblogs.java.net/blog/guruwons/archive/2006/11/sending_large_f.html
>
> As I mentioned on the comments, I'd like to extend this a little to
> support both out-of-band transfer (e.g. its basically a message with a
> URL in it to that the user can download the file from some remote
> destination) or the file is actually sent over the JMS network, so it
> can act as a facade to the existing JMS Streams feature...
>
> http://incubator.apache.org/activemq/jms-streams.html
>
> So am thinking from a client API perspective they do one of the following...
>
> // send a message out of band...
> FileMessage message = session.createRemoteFileMessage(new
> URL("http:///foo.com/bar.jpg"));
>
> // send a local file over the JMS network
> FileMessage message = session.createLocalFileMessage(new
> File("~/myfiles/bar.jpg"));
>
> then for consumers...
>
> if (message instanceof FileMessage) {
> FileMessage fileMessage = (FileMessage) message;
> InputStream in = fileMessage.getInputStream();
> // lets read the file...
>
> // or lets force the file to be manifested as a local file so we can
> work directly on the file instead
>
> URL url = fileMessage.getURL();
> // we can now open the file as many times as we like...
> }
>
> Thoughts?
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
--
Regards,
Hiram
Blog: http://hiramchirino.com
Re: support for FileMessage?
Posted by Rob Davies <ra...@gmail.com>.
like it! I guess it's already implemented by now :)
On 16 Nov 2006, at 09:01, James Strachan wrote:
> Saw an interesting blog post today...
>
> http://weblogs.java.net/blog/guruwons/archive/2006/11/
> sending_large_f.html
>
> As I mentioned on the comments, I'd like to extend this a little to
> support both out-of-band transfer (e.g. its basically a message with a
> URL in it to that the user can download the file from some remote
> destination) or the file is actually sent over the JMS network, so it
> can act as a facade to the existing JMS Streams feature...
>
> http://incubator.apache.org/activemq/jms-streams.html
>
> So am thinking from a client API perspective they do one of the
> following...
>
> // send a message out of band...
> FileMessage message = session.createRemoteFileMessage(new
> URL("http:///foo.com/bar.jpg"));
>
> // send a local file over the JMS network
> FileMessage message = session.createLocalFileMessage(new
> File("~/myfiles/bar.jpg"));
>
> then for consumers...
>
> if (message instanceof FileMessage) {
> FileMessage fileMessage = (FileMessage) message;
> InputStream in = fileMessage.getInputStream();
> // lets read the file...
>
> // or lets force the file to be manifested as a local file so we can
> work directly on the file instead
>
> URL url = fileMessage.getURL();
> // we can now open the file as many times as we like...
> }
>
> Thoughts?
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/