You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by JG <gi...@discoverbeyond.com> on 2013/06/27 17:26:50 UTC
JMS to Websocket using camel routes question
Hi,
I've been trying to create a camel route from a JMS queue to a websocket
queue using activemq, but I've hit a wall, and I'm not sure where to go from
here given the examples in activemq or online. It seems I have all the
components working, but I just can't connect them.
I'm using ActiveMQ 5.8.0, Camel 2.10.4, running on OSX 10.8.4 with (Apple)
Java 1.6.0_51, and stomp.js
Here's what I've done so far:
Added to activemq.xml
...
<transportConnectors>
...
<transportConnector name="websocket" uri="ws://0.0.0.0:61614"/>
</transportConnectors>
...
<import resource="camel.xml"/>
...
Added route to camel.xml
...
<route>
<from uri="activemq:queue:fooQ"/>
<to uri="activemq:queue:fooA"/>
<to uri="websocket://foo?sendToAll=true"/>
//
</route>
...
Downloaded camel (2.10.4) and copied *camel-websocket-2.10.4.jar* to
*lib/camel*
Started activemq like so: *./activemq camel*
No errors reported and the route started: console output
<http://pastebin.com/kSmfdGvP>
I publish data to the queue fooQ from java and I do receive the data in my
consuming app listening to fooA, but the html5 page using stomp.js never
receives the data.
Here's what I have in the html 5 page:
<script type="text/javascript">
var url = "ws://localhost:61614/stomp";
var client = Stomp.client(url);
var connect_callback = function() {
alert('connected');
var onmessage = function(message) {
alert('msg received: ' + message.body);
// called every time the client receives a message
}
client.subscribe("foo", onmessage);
};
client.connect('guest', 'guest', connect_callback);
I've been searching online for similar examples but really haven't found any
that helped. Any help would be really appreciated.
Also, I can send ws messages from the included chat.js demo to my html5 and
it's received without an issue. It's just the JMS to WS that's not working.
-Jeremy
--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-to-Websocket-using-camel-routes-question-tp4668650.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: JMS to Websocket using camel routes question
Posted by JG <gi...@discoverbeyond.com>.
Thank you for clearing that up, and I was able to get it working for both
queues and topics. So that was definitely my disconnect.
Again, thank you for the clarification and helping me connect things.
-Jeremy
--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-to-Websocket-using-camel-routes-question-tp4668650p4668675.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: JMS to Websocket using camel routes question
Posted by Christian Posta <ch...@gmail.com>.
So there might be some disconnect here...
Your HTML client is subscribing to queue foo.... but that's not a queue..
that's the websocket endpoint you've exposed on your camel route... the
queue that your HTML app can consume from is fooA...
The websocket producer in camel actually exposes a web endpoint that is
websocket enabled to which clients can connect and consume data. You can
take a look at the camel twitter websocket example to see more clearly.
On Thu, Jun 27, 2013 at 8:26 AM, JG <gi...@discoverbeyond.com> wrote:
> Hi,
>
> I've been trying to create a camel route from a JMS queue to a websocket
> queue using activemq, but I've hit a wall, and I'm not sure where to go
> from
> here given the examples in activemq or online. It seems I have all the
> components working, but I just can't connect them.
>
> I'm using ActiveMQ 5.8.0, Camel 2.10.4, running on OSX 10.8.4 with (Apple)
> Java 1.6.0_51, and stomp.js
>
> Here's what I've done so far:
>
> Added to activemq.xml
> ...
> <transportConnectors>
> ...
> <transportConnector name="websocket" uri="ws://0.0.0.0:61614
> "/>
> </transportConnectors>
> ...
> <import resource="camel.xml"/>
> ...
>
> Added route to camel.xml
> ...
> <route>
> <from uri="activemq:queue:fooQ"/>
> <to uri="activemq:queue:fooA"/>
> <to uri="websocket://foo?sendToAll=true"/>
> //
>
> </route>
> ...
>
> Downloaded camel (2.10.4) and copied *camel-websocket-2.10.4.jar* to
> *lib/camel*
>
> Started activemq like so: *./activemq camel*
>
> No errors reported and the route started: console output
> <http://pastebin.com/kSmfdGvP>
>
> I publish data to the queue fooQ from java and I do receive the data in my
> consuming app listening to fooA, but the html5 page using stomp.js never
> receives the data.
>
> Here's what I have in the html 5 page:
>
> <script type="text/javascript">
>
> var url = "ws://localhost:61614/stomp";
> var client = Stomp.client(url);
>
> var connect_callback = function() {
> alert('connected');
>
> var onmessage = function(message) {
> alert('msg received: ' + message.body);
> // called every time the client receives a message
> }
> client.subscribe("foo", onmessage);
>
> };
>
> client.connect('guest', 'guest', connect_callback);
>
> I've been searching online for similar examples but really haven't found
> any
> that helped. Any help would be really appreciated.
>
> Also, I can send ws messages from the included chat.js demo to my html5 and
> it's received without an issue. It's just the JMS to WS that's not
> working.
>
> -Jeremy
>
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/JMS-to-Websocket-using-camel-routes-question-tp4668650.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
--
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta