You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ako <an...@koelewijn.net> on 2013/10/13 16:52:06 UTC

Camel consuming from apache mq using stomp over websockets

Hi,

I want to create a camel route which consumes messages from an ActiveMQ
topic. There's a firewall between the camel code and the ActiveMQ broker,
the broker can only expose ports 80 and 443. Is it possible to create a
camel route which receives messages from the broker using stomp over
websockets?

The broker has a websocket connector:

        BrokerService brokerSvc = new BrokerService();
        brokerSvc.setBrokerName("brkr1");
        brokerSvc.addConnector("ws://localhost:80?trace=true");
        brokerSvc.setPersistent(false);
        brokerSvc.start();

For the camel route i have the following code:

        StompComponent stompComponent = new StompComponent();
        stompComponent.setBrokerURL("ws://localhost:80");
        camelContext.addComponent("stomp",stompComponent);

                from("stomp:topic:test").
                        log(LoggingLevel.INFO, "received websocket msg
${id}, ${body}").
                        setBody(simple("${body.ascii.toString()}")).
                        to("file:///c:/tmp/to-stomp");

When i run this i get the following error:
...
Caused by: java.lang.Exception: Unsupported URI scheme 'ws'
	at org.fusesource.stomp.client.Stomp.connectCallback(Stomp.java:119)
	at
org.apache.camel.component.stomp.StompEndpoint.doStart(StompEndpoint.java:73)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
...

Using ActiveMQ 5.8.0 and Camel 2.12.1.

Is this possible at all?

Thanks,
Andrej




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel consuming from apache mq using stomp over websockets

Posted by MichaelAtSAG <me...@gmail.com>.
Andrej,

I am hitting the same restriction. Were you able to connect stomp endpoint
to use websocket or is there another workaround that I am not reading in
this comment thread?

Thanks,
Michael

Hitting this:

Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint:
stomp://destination:app/nerv-tweet-route?brokerURL=ws%3A%2F%2Flocalhost%3A61614
due to: Unsupported URI scheme 'ws'



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476p5753657.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel consuming from apache mq using stomp over websockets

Posted by Christian Posta <ch...@gmail.com>.
Ahh, i missed that. In your OP you mention you want to connect Camel to
ActiveMQ which is behind a firewall. For that the http transport should
work fine.

If you're sending messages from a browser directly to the broker, STOMP
over WebSockets should be work.

If you're getting a BindAddressException on the broker start up, check to
see what's already listening to those ports that you've specified
(transports, jmx, etc).



On Mon, Oct 14, 2013 at 6:53 PM, ako <an...@koelewijn.net> wrote:

> Because i want to deliver messages to the queue from a webbrowser. The
> broker will be behind a firewall, only able to use ports 80 and 443.
> The camel route should also connect to the same broker over the same port
> to consume messages from the same queue.
>
>
>
>
>
>   +-------------+         +--------------+          +----------------+
>   |             |         |              |          |                |
>   |             |         |              |          |                |
>   |             |Stomp+ws |              |Stomp+ws  |                |
>   |   Browser   +-------->|   Firewall   +--------->|-     Broker    |
>   |             |         |              |          |                |
>   |             |         |              |<---------+                |
>   |             |         |              |          |                |
>   +-------------+         +----- -+------+          +----------------+
>                                   |
>                                   |Stomp+ws
>                                   |
>                                   v
>                           +--------------+
>                           |              |
>                           |              |
>                           |    Camel     |
>                           |              |
>                           +--------------+
>
>
> On Tue, Oct 15, 2013 at 1:40 AM, ceposta [via Camel] <
> ml-node+s465427n5741568h95@n5.nabble.com> wrote:
>
> > Why don't you use the http transport? Don't need WS for this...
> >
> > http://activemq.apache.org/http-and-https-transports-reference.html
> >
> >
> >
> > On Sun, Oct 13, 2013 at 7:52 AM, ako <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=5741568&i=0>>
> > wrote:
> >
> > > Hi,
> > >
> > > I want to create a camel route which consumes messages from an ActiveMQ
> > > topic. There's a firewall between the camel code and the ActiveMQ
> > broker,
> > > the broker can only expose ports 80 and 443. Is it possible to create a
> > > camel route which receives messages from the broker using stomp over
> > > websockets?
> > >
> > > The broker has a websocket connector:
> > >
> > >         BrokerService brokerSvc = new BrokerService();
> > >         brokerSvc.setBrokerName("brkr1");
> > >         brokerSvc.addConnector("ws://localhost:80?trace=true");
> > >         brokerSvc.setPersistent(false);
> > >         brokerSvc.start();
> > >
> > > For the camel route i have the following code:
> > >
> > >         StompComponent stompComponent = new StompComponent();
> > >         stompComponent.setBrokerURL("ws://localhost:80");
> > >         camelContext.addComponent("stomp",stompComponent);
> > >
> > >                 from("stomp:topic:test").
> > >                         log(LoggingLevel.INFO, "received websocket msg
> > > ${id}, ${body}").
> > >                         setBody(simple("${body.ascii.toString()}")).
> > >                         to("file:///c:/tmp/to-stomp");
> > >
> > > When i run this i get the following error:
> > > ...
> > > Caused by: java.lang.Exception: Unsupported URI scheme 'ws'
> > >         at
> > > org.fusesource.stomp.client.Stomp.connectCallback(Stomp.java:119)
> > >         at
> > >
> > >
> >
> org.apache.camel.component.stomp.StompEndpoint.doStart(StompEndpoint.java:73)
> >
> > >         at
> > > org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> > > ...
> > >
> > > Using ActiveMQ 5.8.0 and Camel 2.12.1.
> > >
> > > Is this possible at all?
> > >
> > > Thanks,
> > > Andrej
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476.html
> > > Sent from the Camel - Users mailing list archive at Nabble.com.
> > >
> >
> >
> >
> > --
> > *Christian Posta*
> > http://www.christianposta.com/blog
> > twitter: @christianposta
> >  http://www.christianposta.com/blog
> >
> >
> > ------------------------------
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476p5741568.html
> >  To unsubscribe from Camel consuming from apache mq using stomp over
> > websockets, click here<
> http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5741476&code=YW5kcmVqQGtvZWxld2lqbi5uZXR8NTc0MTQ3NnwxMjcxNTM4ODEz
> >
> > .
> > NAML<
> http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476p5741569.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Camel consuming from apache mq using stomp over websockets

Posted by ako <an...@koelewijn.net>.
Because i want to deliver messages to the queue from a webbrowser. The
broker will be behind a firewall, only able to use ports 80 and 443.
The camel route should also connect to the same broker over the same port
to consume messages from the same queue.





  +-------------+         +--------------+          +----------------+
  |             |         |              |          |                |
  |             |         |              |          |                |
  |             |Stomp+ws |              |Stomp+ws  |                |
  |   Browser   +-------->|   Firewall   +--------->|-     Broker    |
  |             |         |              |          |                |
  |             |         |              |<---------+                |
  |             |         |              |          |                |
  +-------------+         +----- -+------+          +----------------+
                                  |
                                  |Stomp+ws
                                  |
                                  v
                          +--------------+
                          |              |
                          |              |
                          |    Camel     |
                          |              |
                          +--------------+


On Tue, Oct 15, 2013 at 1:40 AM, ceposta [via Camel] <
ml-node+s465427n5741568h95@n5.nabble.com> wrote:

> Why don't you use the http transport? Don't need WS for this...
>
> http://activemq.apache.org/http-and-https-transports-reference.html
>
>
>
> On Sun, Oct 13, 2013 at 7:52 AM, ako <[hidden email]<http://user/SendEmail.jtp?type=node&node=5741568&i=0>>
> wrote:
>
> > Hi,
> >
> > I want to create a camel route which consumes messages from an ActiveMQ
> > topic. There's a firewall between the camel code and the ActiveMQ
> broker,
> > the broker can only expose ports 80 and 443. Is it possible to create a
> > camel route which receives messages from the broker using stomp over
> > websockets?
> >
> > The broker has a websocket connector:
> >
> >         BrokerService brokerSvc = new BrokerService();
> >         brokerSvc.setBrokerName("brkr1");
> >         brokerSvc.addConnector("ws://localhost:80?trace=true");
> >         brokerSvc.setPersistent(false);
> >         brokerSvc.start();
> >
> > For the camel route i have the following code:
> >
> >         StompComponent stompComponent = new StompComponent();
> >         stompComponent.setBrokerURL("ws://localhost:80");
> >         camelContext.addComponent("stomp",stompComponent);
> >
> >                 from("stomp:topic:test").
> >                         log(LoggingLevel.INFO, "received websocket msg
> > ${id}, ${body}").
> >                         setBody(simple("${body.ascii.toString()}")).
> >                         to("file:///c:/tmp/to-stomp");
> >
> > When i run this i get the following error:
> > ...
> > Caused by: java.lang.Exception: Unsupported URI scheme 'ws'
> >         at
> > org.fusesource.stomp.client.Stomp.connectCallback(Stomp.java:119)
> >         at
> >
> >
> org.apache.camel.component.stomp.StompEndpoint.doStart(StompEndpoint.java:73)
>
> >         at
> > org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> > ...
> >
> > Using ActiveMQ 5.8.0 and Camel 2.12.1.
> >
> > Is this possible at all?
> >
> > Thanks,
> > Andrej
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
>
>
> --
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta
>  http://www.christianposta.com/blog
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476p5741568.html
>  To unsubscribe from Camel consuming from apache mq using stomp over
> websockets, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5741476&code=YW5kcmVqQGtvZWxld2lqbi5uZXR8NTc0MTQ3NnwxMjcxNTM4ODEz>
> .
> NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476p5741569.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel consuming from apache mq using stomp over websockets

Posted by Christian Posta <ch...@gmail.com>.
Why don't you use the http transport? Don't need WS for this...

http://activemq.apache.org/http-and-https-transports-reference.html


On Sun, Oct 13, 2013 at 7:52 AM, ako <an...@koelewijn.net> wrote:

> Hi,
>
> I want to create a camel route which consumes messages from an ActiveMQ
> topic. There's a firewall between the camel code and the ActiveMQ broker,
> the broker can only expose ports 80 and 443. Is it possible to create a
> camel route which receives messages from the broker using stomp over
> websockets?
>
> The broker has a websocket connector:
>
>         BrokerService brokerSvc = new BrokerService();
>         brokerSvc.setBrokerName("brkr1");
>         brokerSvc.addConnector("ws://localhost:80?trace=true");
>         brokerSvc.setPersistent(false);
>         brokerSvc.start();
>
> For the camel route i have the following code:
>
>         StompComponent stompComponent = new StompComponent();
>         stompComponent.setBrokerURL("ws://localhost:80");
>         camelContext.addComponent("stomp",stompComponent);
>
>                 from("stomp:topic:test").
>                         log(LoggingLevel.INFO, "received websocket msg
> ${id}, ${body}").
>                         setBody(simple("${body.ascii.toString()}")).
>                         to("file:///c:/tmp/to-stomp");
>
> When i run this i get the following error:
> ...
> Caused by: java.lang.Exception: Unsupported URI scheme 'ws'
>         at
> org.fusesource.stomp.client.Stomp.connectCallback(Stomp.java:119)
>         at
>
> org.apache.camel.component.stomp.StompEndpoint.doStart(StompEndpoint.java:73)
>         at
> org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> ...
>
> Using ActiveMQ 5.8.0 and Camel 2.12.1.
>
> Is this possible at all?
>
> Thanks,
> Andrej
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Camel consuming from apache mq using stomp over websockets

Posted by ako <an...@koelewijn.net>.
Can get it to work.

1st attempt:

    /* init broker */

    ...

        BrokerService brokerSvc = new BrokerService();
        brokerSvc.setBrokerName("brkr1");
        brokerSvc.addConnector("ws://localhost:61613?trace=true");
    ...

    /* route configuration */

    ....
    from("stomp:topic:test").
        log(LoggingLevel.INFO, "received websocket msg ${id}, ${body}").
        setBody(simple("${body.ascii.toString()}")).
        to("file:///c:/tmp/to-stomp");
    ....

This results in the following exception:

java.net.BindException: Address already in use: bind
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:444)
	at sun.nio.ch.Net.bind(Net.java:436)
	at
sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
	at
org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:187)

Seems like the stomp connector is trying to open a server endpoint, instead
of connecting to the broker as a consuming client.

I've also tried the following for setting up the route:

    from("stomp:topic:test?brokerURL=tcp://localhost:61613").
        log(LoggingLevel.INFO, "received websocket msg ${id}, ${body}").
        setBody(simple("${body.ascii.toString()}")).
        to("file:///c:/tmp/to-stomp");

This results in the following stacktrace:

Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint: stomp://topic:test?brokerURL=tcp%3A%2F%2Flocalhost%3A61613
due to: There are 1 parameters that couldn't be set on the endpoint. Check
the uri if the parameters are spelt correctly and that they are properties
of the endpoint. Unknown parameters=[{brokerURL=tcp://localhost:61613}]
	at
org.apache.camel.impl.DefaultComponent.validateParameters(DefaultComponent.java:189)
	at
org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:134)
	at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:508)
	... 21 more

Which kind of weird as the documentation page for stomp indicates that you
can set a brokerURL parameter on the endpoint...

Thanks for helping,
Andrej



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476p5741566.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel consuming from apache mq using stomp over websockets

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I think the protocol in camel-stomp should be defined as tcp.
http://camel.apache.org/stomp



On Sun, Oct 13, 2013 at 4:52 PM, ako <an...@koelewijn.net> wrote:
> Hi,
>
> I want to create a camel route which consumes messages from an ActiveMQ
> topic. There's a firewall between the camel code and the ActiveMQ broker,
> the broker can only expose ports 80 and 443. Is it possible to create a
> camel route which receives messages from the broker using stomp over
> websockets?
>
> The broker has a websocket connector:
>
>         BrokerService brokerSvc = new BrokerService();
>         brokerSvc.setBrokerName("brkr1");
>         brokerSvc.addConnector("ws://localhost:80?trace=true");
>         brokerSvc.setPersistent(false);
>         brokerSvc.start();
>
> For the camel route i have the following code:
>
>         StompComponent stompComponent = new StompComponent();
>         stompComponent.setBrokerURL("ws://localhost:80");
>         camelContext.addComponent("stomp",stompComponent);
>
>                 from("stomp:topic:test").
>                         log(LoggingLevel.INFO, "received websocket msg
> ${id}, ${body}").
>                         setBody(simple("${body.ascii.toString()}")).
>                         to("file:///c:/tmp/to-stomp");
>
> When i run this i get the following error:
> ...
> Caused by: java.lang.Exception: Unsupported URI scheme 'ws'
>         at org.fusesource.stomp.client.Stomp.connectCallback(Stomp.java:119)
>         at
> org.apache.camel.component.stomp.StompEndpoint.doStart(StompEndpoint.java:73)
>         at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
> ...
>
> Using ActiveMQ 5.8.0 and Camel 2.12.1.
>
> Is this possible at all?
>
> Thanks,
> Andrej
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-consuming-from-apache-mq-using-stomp-over-websockets-tp5741476.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen