Maybe save the http data as a String is not a best way, but it is a usable way. If I want to send no String data like image or some objects, I should do some additional works.
Claus Ibsen-2 wrote: > > On Mon, Jan 11, 2010 at 7:00 AM, ztesoft <[email protected]> wrote: >> >> Dears, I try to use multicast to save the received message into two files >> using >> "from("jetty:http://0.0.0.0:8080/").multicast().to("file://output","file://output1");" >> It works correctly. Two files will be saved in /output/.camel/ and >> /output1/.camel/ folders separately. >> >> But if I use activemq for a endpoint, there may be something wrong. >> 1st. I use activemy queue instead of the second endpoint. >> >> from("jetty:http://0.0.0.0:8080/").multicast().to("file://output","test-jms:queue:test.queue"); >> from("test-jms:queue:test.queue").process(new Processor() { >> public void process(Exchange e) throws IOException { >> System.out.println("Received exchange: " + >> e.getIn()); >> >> System.out.println(e.getIn().getBody(String.class)); >> } >> }); >> } >> }); >> In this case, when I send a HTTP request, the result is one file saved in >> /output/ folder and a message displayed in console. The content of this >> message is: >> "Received exchange: JmsMessage: ActiveMQBytesMessage {commandId = 5, >> responseRequired = true, messageId = >> ID:chenyi-4710-1263188603156-2:2:1:1:1, >> originalDestination = null, originalTransactionId = null, producerId = >> ID:chenyi-4710-1263188603156-2:2:1:1, destination = queue://test.queue, >> transactionId = null, expiration = 1263188625859, timestamp = >> 1263188605859, >> arrival = 0, brokerInTime = 1263188605859, brokerOutTime = 1263188605859, >> correlationId = 5a1b6157-a4cb-4f8a-aa78-82519a776bf0, replyTo = >> temp-queue://ID:chenyi-4710-1263188603156-2:1:1, persistent = true, type >> = >> null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = >> null, compressed = false, userID = null, content = >> org.apache.activemq.util.byteseque...@6a63d3, marshalledProperties = >> null, >> dataStructure = null, redeliveryCounter = 0, size = 1024, properties = >> {CamelHttpUrl=http://127.0.0.1:8080/, >> Content_HYPHEN_Type=text/xml;charset=UTF-8, Host=127.0.0.1:8080, >> CamelHttpMethod=POST, Content_HYPHEN_Length=681, >> SOAPAction="http://www.ctcc.com/service/sendSms", >> CamelHttpCharacterEncoding=UTF-8, User_HYPHEN_Agent=Jakarta >> Commons-HttpClient/3.0.1, CamelHttpPath=/, CamelHttpUri=/}, >> readOnlyProperties = true, readOnlyBody = true, droppable = false} >> ActiveMQBytesMessage{ bytesOut = null, dataOut = null, dataIn = >> java.io.datainputstr...@bfed5a }" >> >> 2nd. >> I change the order for the multicast endpoint. >> >> from("jetty:http://0.0.0.0:8080/").multicast().to("test-jms:queue:test.queue","file://output"); >> from("test-jms:queue:test.queue").process(new Processor() { >> public void process(Exchange e) throws IOException { >> System.out.println("Received exchange: " + >> e.getIn()); >> >> System.out.println(e.getIn().getBody(String.class)); >> } >> }); >> } >> }); >> In this case, when I send a HTTP request, the message displayed correctly >> in >> th console(the http request body displayed). But there is not any file >> saved >> in any folder. >> >> Does anyone know the reasons and how to solve this problem? >> -- > > Use .convertBodyTo(String.class) after the from. This will store the > HTTP data as a String which can be safely duplicated when you do a > multicast. > > > >> View this message in context: >> http://old.nabble.com/Question-about-multicasting.-tp27106219p27106219.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> > > > > -- > Claus Ibsen > Apache Camel Committer > > Author of Camel in Action: http://www.manning.com/ibsen/ > Open Source Integration: http://fusesource.com > Blog: http://davsclaus.blogspot.com/ > Twitter: http://twitter.com/davsclaus > > -- View this message in context: http://old.nabble.com/Question-about-multicasting.-tp27106219p27106521.html Sent from the Camel - Users mailing list archive at Nabble.com.
