-
15. Re: Problem in getting browser values through camel
davsclaus Feb 14, 2011 2:59 AM (in response to praga)You need to use activemq instead of jms. And you should configure the activemq component to connect to the JMS broker you use.
-
16. Re: Problem in getting browser values through camel
praga Feb 16, 2011 1:28 AM (in response to davsclaus)Hi ,
Thanks a lot for that idea. PollingConsumer is working fine now and iam able to fetch the values back from queue. here is my exchange
printing exchange :::Exchange[JmsMessage: ActiveMQMessage {commandId = 5, responseRequired = true, messageId = ID:01HW195837-1465-1297675483829-0:38:1:1:1,
originalDestination = null, originalTransactionId = null, producerId = ID:01HW195837-1465-1297675483829-0:38:1:1, destination = queue://HTTPQueueNew,
transactionId = null, expiration = 0, timestamp = 1297836785866, arrival = 0, brokerInTime = 1297836785866, brokerOutTime = 1297836786226, correlatio
nId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = fal
se, userID = null, content = null, marshalledProperties = org.apache.activemq.util.ByteSequence@3d725b, dataStructure = null, redeliveryCounter = 0, s
ize = 0, properties = {Accept_HYPHEN_Encoding=gzip, deflate, UA_HYPHEN_CPU=x86, CamelHttpMethod=GET, Host=localhost:8080, CamelHttpQuery=name=praga,
Connection=Keep-Alive, User_HYPHEN_Agent=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 3.0.04506.30; .NET CLR 2.0.50727; MS-RTC LM 8), C
amelHttpUri=/HHTPtoJMSInFuse, Accept_HYPHEN_Language=en-us, CamelHttpPath=/HHTPtoJMSInFuse, CamelHttpUrl=http://localhost:8080/HHTPtoJMSInFuse, name=praga, Accept=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, applic
ation/x-ms-application, application/x-shockwave-flash, /}, readOnlyProperties = true, readOnlyBody = true, droppable = false}]
how to post the value name=praga from this exchange back to the browser ?
I tried a sample
exchange.getOut().setBody("Book 123 is Camel in Action");
this is working fine. But it is hard coded value. How to send my value that was taken from queue back to the http browser?
-
17. Re: Problem in getting browser values through camel
davsclaus Feb 16, 2011 1:34 AM (in response to praga)Just grab whatever information you need from the Exchange that the PollingConsumer returns to you. And then store that information in the Exchange from the route.
If you use a Camel Processor then
public void process(Exchange exchange) throws Exception { ... Exchange jmsExchange = ... // polling consumer ... // get stuff from jmsExchange and put in exchange String body = jmsExchange.getIn().getBody(String.class); String foo = jmsExchange.getIn().getHeader("foo", String.class); .. exchange.getOut().setBody("Hey this is from JMS " + body); exchange.getOut().setHeader("name", foo);
-
18. Re: Problem in getting browser values through camel
praga Feb 16, 2011 2:09 AM (in response to davsclaus)Hi,
I actually tried that but my body is printed null
camelContext.addComponent("activemq", activeMQComponent("tcp://localhost:61616"));
Endpoint endpoint = context.getEndpoint("activemq:queue:HTTPQueueNew");
PollingConsumer consumer = endpoint.createPollingConsumer();
Exchange exchange = consumer.receive();
System.out.println("printing exchange :::"+exchange);
String response = exchange.getIn().getBody(String.class);
System.out.println("response:::"+response);
but my response is null... I have printed my exchange in my previous post.
-
19. Re: Problem in getting browser values through camel
praga Feb 16, 2011 3:59 AM (in response to praga)Hi,
When I tried using consumerTemplate.receiveBody iam getting null. Basically the body is null from queue. But if i see the exchange , the value is printed. Where could be the problem?
-
20. Re: Problem in getting browser values through camel
praga Feb 16, 2011 5:11 AM (in response to praga)Hi,
Its working fine now. All i had to do is change my HTTP Request to string and then place it in queue.