Hi So I got the latest SNAPSHOT and the bean binding issue as well as the camel-http getResponse issue have been fixed. Thank you so much for that. The last issue I am currently stuck on is the following code:
String body = exchange.getIn().getBody(Sting.class); I still get an empty String back from this. Regards Claus Ibsen-2 wrote: > > On Fri, Aug 7, 2009 at 2:40 AM, jjb<jj_burf...@yahoo.com> wrote: >> >> Hi >> >> I have another question regarding how to obtain the body of the HTTP >> message. Before the latest SNAPSHOT (in 2.0-M2), I used to be able to do >> this: >> >> String body = (String)exchange.getIn().getBody((new >> String()).getClass()); >> >> This now gives me an empty String. Do you know how I can get the body of >> an >> HTTP post now? > > String body = exchange.getIn().getBody(Sting.class); > should work. > > >> >> Regards >> >> >> jjb wrote: >>> >>> Hi, Claus. >>> >>> I was hoping to get the latest SNAPSHOT with the HttpMessage.getResponse >>> method implemented. I just updated from the SNAPSHOT repo and verified >>> it's not there yet: >>> >>> stealth: wget --no-check-certificate >>> https://repository.apache.org/content/repositories/snapshots//org/apache/camel/camel-http/2.0-SNAPSHOT/camel-http-2.0-SNAPSHOT.jar >>> --2009-08-06 15:28:08-- >>> https://repository.apache.org/content/repositories/snapshots//org/apache/camel/camel-http/2.0-SNAPSHOT/camel-http-2.0-SNAPSHOT.jar >>> Resolving repository.apache.org... 140.211.11.100 >>> Connecting to repository.apache.org|140.211.11.100|:443... connected. >>> WARNING: cannot verify repository.apache.org's certificate, issued by >>> `/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, >>> Inc./OU=http://certificates.godaddy.com/repository/CN=Go Daddy Secure >>> Certification Authority/serialNumber=07969287': >>> Self-signed certificate encountered. >>> HTTP request sent, awaiting response... 200 OK >>> Length: 42721 (42K) [text/plain] >>> Saving to: `camel-http-2.0-SNAPSHOT.jar' >>> >>> 100%[=================================================================================================================================================>] >>> 42,721 73.7K/s in 0.6s >>> >>> 2009-08-06 15:28:09 (73.7 KB/s) - `camel-http-2.0-SNAPSHOT.jar' saved >>> [42721/42721] >>> >>> stealth: javap -classpath camel-http-2.0-SNAPSHOT.jar >>> org.apache.camel.component.http.HttpMessage >>> Compiled from "HttpMessage.java" >>> public class org.apache.camel.component.http.HttpMessage extends >>> org.apache.camel.impl.DefaultMessage{ >>> public >>> org.apache.camel.component.http.HttpMessage(org.apache.camel.Exchange, >>> javax.servlet.http.HttpServletRequest); >>> public javax.servlet.http.HttpServletRequest getRequest(); >>> protected java.lang.Object createBody(); >>> } >>> >>> stealth: >>> >>> >>> Do you know when it might make it into the repo? >>> >>> Thanks! >>> >>> >>> Claus Ibsen-2 wrote: >>>> >>>> Hi >>>> >>>> Also the bean method name issue has been fixed in trunk. >>>> So if possible please test it at your side by building from source or >>>> try SNAPSHOT when a new build is published to apache maven repos. >>>> >>>> On Wed, Aug 5, 2009 at 1:55 PM, Claus Ibsen<claus.ib...@gmail.com> >>>> wrote: >>>>> Hi >>>>> >>>>> Okay I am committing a fix in short time. >>>>> >>>>> You can grab it using 2 ways >>>>> - from the body using the camel type converter, to avoid ugly java >>>>> type >>>>> casts >>>>> - using java type cast to cast the message to HttpMessage >>>>> >>>>> // we have access to the HttpServletRequest here and we >>>>> can grab it if we need it >>>>> HttpServletRequest req = >>>>> exchange.getIn().getBody(HttpServletRequest.class); >>>>> assertNotNull(req); >>>>> >>>>> // we have access to the HttpServletResponse here and we >>>>> can grab it if we need it >>>>> HttpServletResponse res = >>>>> exchange.getIn().getBody(HttpServletResponse.class); >>>>> assertNotNull(res); >>>>> >>>>> // and they should also be on HttpMessage >>>>> HttpMessage msg = (HttpMessage) exchange.getIn(); >>>>> assertNotNull(msg.getRequest()); >>>>> assertNotNull(msg.getResponse()); >>>>> >>>>> And use the output stream to write to the servlet response >>>>> >>>>> // and we can use servlet response to write to output >>>>> stream >>>>> also >>>>> res.getOutputStream().print("Written by servlet response"); >>>>> >>>>> >>>>> On Wed, Aug 5, 2009 at 10:55 AM, Claus Ibsen<claus.ib...@gmail.com> >>>>> wrote: >>>>>> Hi >>>>>> >>>>>> Cool I have added a ticket to get it back >>>>>> https://issues.apache.org/activemq/browse/CAMEL-1879 >>>>>> >>>>>> >>>>>> On Wed, Aug 5, 2009 at 10:52 AM, jjb<jj_burf...@yahoo.com> wrote: >>>>>>> >>>>>>> Hi, Claus. >>>>>>> >>>>>>> I built a framework to receive status related messages from a topic >>>>>>> as >>>>>>> the >>>>>>> route is traversed. Consider the routes the define DerivedClass -> >>>>>>> A >>>>>>> -> B >>>>>>> -> C. As each segment in the route executes, it sends JAXB/XML >>>>>>> messages to >>>>>>> a topic that are then forwarded back to the client via a callback. >>>>>>> As >>>>>>> the >>>>>>> DerivedClass receives these messages, it sends them back over the >>>>>>> HTTP >>>>>>> socket (via the HttpServletResponse) to the invoking web client. >>>>>>> This >>>>>>> gives >>>>>>> the web client a realtime flow of XML status updates while the >>>>>>> different >>>>>>> endpoints are traversed. Since I do not want DerivedClass to know >>>>>>> about >>>>>>> Camel or JMS, there is a class which DerivedClass submits a request >>>>>>> to >>>>>>> (manager instance below) that also listens on this topic for related >>>>>>> status >>>>>>> messages. These I get via callback and write them to the web client >>>>>>> accordingly: >>>>>>> >>>>>>> >>>>>>> public interface Client >>>>>>> { >>>>>>> public void notify(String status); >>>>>>> } >>>>>>> >>>>>>> public DerivedClass implements Client >>>>>>> { >>>>>>> HttpServletResponse response; >>>>>>> >>>>>>> public void process(Exchange exchange) >>>>>>> { >>>>>>> HttpServletResponse response = ....; // need to know how to >>>>>>> get >>>>>>> this >>>>>>> String request = "MY XML REQUEST"; // this is actually a >>>>>>> JAXB >>>>>>> serialized object >>>>>>> >>>>>>> // submit XML request to class which listens on topic and >>>>>>> calls >>>>>>> notify with stuff for us >>>>>>> manager.submit(request, this); >>>>>>> } >>>>>>> >>>>>>> // we get our stuff from the manager object which listens on a >>>>>>> topic and >>>>>>> correlates status >>>>>>> // messages and calls this notify method >>>>>>> public notify(String status) >>>>>>> { >>>>>>> response.getWriter().println(status); >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> I was hoping 2.0-M3 Camel would allow access to HttpServletRequest >>>>>>> as >>>>>>> before >>>>>>> 2.0-M3 so I can make my own synchronous writes to the HTTP client >>>>>>> from >>>>>>> DerivedClass with no dependence on Camel. >>>>>>> >>>>>>> Regards >>>>>>> >>>>>>> response.getWriter().println(statusStr) >>>>>>> >>>>>>> Claus Ibsen-2 wrote: >>>>>>>> >>>>>>>> Hi >>>>>>>> >>>>>>>> Ah the response may be missing on the HttpMessage. >>>>>>>> >>>>>>>> What do you need it for? >>>>>>>> >>>>>>>> On Wed, Aug 5, 2009 at 9:51 AM, jjb<jj_burf...@yahoo.com> wrote: >>>>>>>>> >>>>>>>>> Hi, Claus. >>>>>>>>> >>>>>>>>> Thank you so much for looking into the issue. My last request has >>>>>>>>> to do >>>>>>>>> with how to obtain a reference to the HttpServletResponse in the >>>>>>>>> new >>>>>>>>> (>= >>>>>>>>> 2.0-M3) Camel API. I can get the HttpServletRequest as you >>>>>>>>> suggested >>>>>>>>> (using >>>>>>>>> HttpMessage), but how do I obtain a reference to the >>>>>>>>> HttpServletResponse >>>>>>>>> from a method with is the "to" endpoint of a camel-jetty "from" >>>>>>>>> route >>>>>>>>> that >>>>>>>>> takes an Exchange parameter as so: >>>>>>>>> >>>>>>>>> public void process(Exchange exchange) >>>>>>>>> { >>>>>>>>> HttpMessage in = (HttpMessag) exchange.getIn(); >>>>>>>>> HttpServletRequest = in.getRequest(); >>>>>>>>> >>>>>>>>> // how do I get to the HttpServletResponse which used to be >>>>>>>>> accessed < >>>>>>>>> 2.0-M3 >>>>>>>>> // like this: HttpServletResponse response = >>>>>>>>> ((HttpExchange)exchange).getResponse(); >>>>>>>>> } >>>>>>>>> >>>>>>>>> Regards >>>>>>>>> >>>>>>>>> >>>>>>>>> Claus Ibsen-2 wrote: >>>>>>>>>> >>>>>>>>>> Hi >>>>>>>>>> >>>>>>>>>> Thanks for the sample. I can reproduce the issue. >>>>>>>>>> >>>>>>>>>> The issue is that your base class implements the >>>>>>>>>> javax.jms.MessageListener. >>>>>>>>>> I will dig into why Camel prefers to invoke this method over the >>>>>>>>>> method name specified. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Tue, Aug 4, 2009 at 8:02 PM, jjb<jj_burf...@yahoo.com> wrote: >>>>>>>>>>> >>>>>>>>>>> Hi. >>>>>>>>>>> >>>>>>>>>>> Attached is an example which recreates the bean issue. My goal >>>>>>>>>>> is >>>>>>>>>>> to >>>>>>>>>>> create >>>>>>>>>>> a framework which localizes JMS/ActiveMQ and Camel stuff to one >>>>>>>>>>> package. >>>>>>>>>>> Then none of our business logic depends on it (it just passes >>>>>>>>>>> POJOs >>>>>>>>>>> around >>>>>>>>>>> that are created from XSD using JAXB). This is why I can't put >>>>>>>>>>> the >>>>>>>>>>> @Handler >>>>>>>>>>> annotation in the DerivedClass. >>>>>>>>>>> http://www.nabble.com/file/p24813432/camel_bug.tgz camel_bug.tgz >>>>>>>>>>> >>>>>>>>>>> About the 2.0-M3 Camel interface for HttpServletResponse - how >>>>>>>>>>> do >>>>>>>>>>> I get >>>>>>>>>>> it >>>>>>>>>>> from the Exchange? >>>>>>>>>>> >>>>>>>>>>> Thanks! >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Claus Ibsen-2 wrote: >>>>>>>>>>>> >>>>>>>>>>>> On Tue, Aug 4, 2009 at 9:26 AM, jjb<jj_burf...@yahoo.com> >>>>>>>>>>>> wrote: >>>>>>>>>>>>> >>>>>>>>>>>>> Hi. >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks for the quick response. I switched to 2.0-M3 and still >>>>>>>>>>>>> had >>>>>>>>>>>>> the >>>>>>>>>>>>> problem - the BaseClass.onMessage still gets called. Is there >>>>>>>>>>>>> a >>>>>>>>>>>>> newer >>>>>>>>>>>>> release or something I can check out that might have this fix? >>>>>>>>>>>>> Also, >>>>>>>>>>>>> when I >>>>>>>>>>>>> use 2.0-M3, how do I get the HttpServletResponse (your >>>>>>>>>>>>> suggestion to >>>>>>>>>>>>> get >>>>>>>>>>>>> the >>>>>>>>>>>>> HttpServletRequest worked for me - thanks)? >>>>>>>>>>>>> >>>>>>>>>>>>> Regards >>>>>>>>>>>> >>>>>>>>>>>> Hi >>>>>>>>>>>> >>>>>>>>>>>> About the bean problem. Could you create a ticket for it and >>>>>>>>>>>> attach a >>>>>>>>>>>> small sample with the issue? >>>>>>>>>>>> >>>>>>>>>>>> You can use the @Handler annotation to mark the method that >>>>>>>>>>>> Camel >>>>>>>>>>>> should use and then avoid using the ?method=xxxx. >>>>>>>>>>>> But I am interested in fixing why method=xxx does not work for >>>>>>>>>>>> you. >>>>>>>>>>>> >>>>>>>>>>>> See more here >>>>>>>>>>>> http://camel.apache.org/bean-binding.html >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> Claus Ibsen-2 wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>> Hi >>>>>>>>>>>>>> >>>>>>>>>>>>>> On Tue, Aug 4, 2009 at 7:52 AM, jjb<jj_burf...@yahoo.com> >>>>>>>>>>>>>> wrote: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I have a hierarchy of objects which looks like this: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> public BaseClass implements javax.jms.MessageListener >>>>>>>>>>>>>>> { >>>>>>>>>>>>>>> public void onMessage(javax.jms.Message message) >>>>>>>>>>>>>>> { >>>>>>>>>>>>>>> // do something >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> public DerivedClass extends BaseClass >>>>>>>>>>>>>>> { >>>>>>>>>>>>>>> public void process(String body) >>>>>>>>>>>>>>> { >>>>>>>>>>>>>>> // do something >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> I then have the following XML in my camel-context.xml: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> <bean id="processor" class="DerivedClass"/> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> <route> >>>>>>>>>>>>>>> <from uri="activemq:request.queue"/> >>>>>>>>>>>>>>> <to uri="bean:processor?method=process"/> >>>>>>>>>>>>>>> </route> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> When I run this code, all messages from request.queue always >>>>>>>>>>>>>>> go to >>>>>>>>>>>>>>> BaseClass.onMessage, even though I explicitly want them to >>>>>>>>>>>>>>> go >>>>>>>>>>>>>>> to >>>>>>>>>>>>>>> DerivedClass.process. Have I done something wrong or is >>>>>>>>>>>>>>> this >>>>>>>>>>>>>>> a bug >>>>>>>>>>>>>>> (I >>>>>>>>>>>>>>> read >>>>>>>>>>>>>>> through the bean binding and it said it would first use >>>>>>>>>>>>>>> methods >>>>>>>>>>>>>>> that >>>>>>>>>>>>>>> were >>>>>>>>>>>>>>> explicitly specified in the bean's method parameter)? >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> We have fixed a bug in this relation in 2.0.x (cant remember >>>>>>>>>>>>>> the >>>>>>>>>>>>>> version, might be the 2.0m3). >>>>>>>>>>>>>> >>>>>>>>>>>>>> In older versions you can work around this by adding an @Body >>>>>>>>>>>>>> annotation to your base class >>>>>>>>>>>>>> public void process(@Body String body) >>>>>>>>>>>>>> And Camel should prefer to use this method. >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> I also notice that the new 2.0-M3 version of camel-http no >>>>>>>>>>>>>>> longer >>>>>>>>>>>>>>> contains >>>>>>>>>>>>>>> the class org.apache.camel.component.http.HttpExchange. >>>>>>>>>>>>>>> Therefore, >>>>>>>>>>>>>>> this >>>>>>>>>>>>>>> code no longer compiles: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> public void process(Exchange exchange) >>>>>>>>>>>>>>> { >>>>>>>>>>>>>>> try >>>>>>>>>>>>>>> { >>>>>>>>>>>>>>> HttpServletResponse response = >>>>>>>>>>>>>>> ((HttpExchange)exchange).getResponse(); >>>>>>>>>>>>>>> HttpServletRequest request = >>>>>>>>>>>>>>> ((HttpExchange)exchange).getRequest(); >>>>>>>>>>>>>>> HttpSession session = null; >>>>>>>>>>>>>>> if (request != null) >>>>>>>>>>>>>>> session = >>>>>>>>>>>>>>> request.getSession(true); >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> catch (Exception e) >>>>>>>>>>>>>>> { e.printStackTrace(); } >>>>>>>>>>>>>>> } >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Is there a new way to get the HttpServletResponse and such >>>>>>>>>>>>>>> from the >>>>>>>>>>>>>>> Exchange >>>>>>>>>>>>>>> parameter? >>>>>>>>>>>>>> >>>>>>>>>>>>>> Its on the HttpMessage instead. >>>>>>>>>>>>>> >>>>>>>>>>>>>> HttpMessage in = (HttpMessag) exchange.getIn(); >>>>>>>>>>>>>> HttpServletRequest = in.getRequest(); >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Regards >>>>>>>>>>>>>>> -- >>>>>>>>>>>>>>> View this message in context: >>>>>>>>>>>>>>> http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24802648.html >>>>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at >>>>>>>>>>>>>>> Nabble.com. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> -- >>>>>>>>>>>>>> Claus Ibsen >>>>>>>>>>>>>> Apache Camel Committer >>>>>>>>>>>>>> >>>>>>>>>>>>>> Open Source Integration: http://fusesource.com >>>>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/ >>>>>>>>>>>>>> Twitter: http://twitter.com/davsclaus >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> View this message in context: >>>>>>>>>>>>> http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24803535.html >>>>>>>>>>>>> Sent from the Camel - Users mailing list archive at >>>>>>>>>>>>> Nabble.com. >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> Claus Ibsen >>>>>>>>>>>> Apache Camel Committer >>>>>>>>>>>> >>>>>>>>>>>> Open Source Integration: http://fusesource.com >>>>>>>>>>>> Blog: http://davsclaus.blogspot.com/ >>>>>>>>>>>> Twitter: http://twitter.com/davsclaus >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> View this message in context: >>>>>>>>>>> http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24813432.html >>>>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Claus Ibsen >>>>>>>>>> Apache Camel Committer >>>>>>>>>> >>>>>>>>>> Open Source Integration: http://fusesource.com >>>>>>>>>> Blog: http://davsclaus.blogspot.com/ >>>>>>>>>> Twitter: http://twitter.com/davsclaus >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> View this message in context: >>>>>>>>> http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24822320.html >>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Claus Ibsen >>>>>>>> Apache Camel Committer >>>>>>>> >>>>>>>> Open Source Integration: http://fusesource.com >>>>>>>> Blog: http://davsclaus.blogspot.com/ >>>>>>>> Twitter: http://twitter.com/davsclaus >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> -- >>>>>>> View this message in context: >>>>>>> http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24823165.html >>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Claus Ibsen >>>>>> Apache Camel Committer >>>>>> >>>>>> Open Source Integration: http://fusesource.com >>>>>> Blog: http://davsclaus.blogspot.com/ >>>>>> Twitter: http://twitter.com/davsclaus >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Claus Ibsen >>>>> Apache Camel Committer >>>>> >>>>> Open Source Integration: http://fusesource.com >>>>> Blog: http://davsclaus.blogspot.com/ >>>>> Twitter: http://twitter.com/davsclaus >>>>> >>>> >>>> >>>> >>>> -- >>>> Claus Ibsen >>>> Apache Camel Committer >>>> >>>> Open Source Integration: http://fusesource.com >>>> Blog: http://davsclaus.blogspot.com/ >>>> Twitter: http://twitter.com/davsclaus >>>> >>>> >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24856990.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> > > > > -- > Claus Ibsen > Apache Camel Committer > > Open Source Integration: http://fusesource.com > Blog: http://davsclaus.blogspot.com/ > Twitter: http://twitter.com/davsclaus > > -- View this message in context: http://www.nabble.com/bean-binding-with-inheritance---2.0-M3-camel-http-tp24802648p24906995.html Sent from the Camel - Users mailing list archive at Nabble.com.