Hi, My comments are in the mail.
Claus Ibsen wrote: > On Fri, May 8, 2009 at 9:31 AM, Charles Moulliard <[email protected]> > wrote: >> Hi, >> >> Is it possible through camel endpoint, producer, consumer, ... (I don't know >> exactly where in camel class), to parameter the output that we would like to >> have from a component/endpoint ? >> >> In the camel-quickfix component, the FIX server implemented (through >> quickFix classes) receives messages in the FIX format and map the content >> into a quickfix.Message (can be of type quickfix, FIX40, quickfix.FIX41, >> ...). >> >> What I would like to do is have the possibility through the Camel endpoint >> to tell to the component that I want to receive the FIX messages mapped or >> not ? >> >> e.g. From("quickfixserver?type=String") or >> From("quickfixserver?type=quickFix.Message") > Something like the CXF component can do with its DataFormat type? > ?dataFormat=String > ?dataFormat=QuickFixMessage > > And it should default to QuickFixMessage Yes, you can take the CxfEndpoint as an example. It leverage the Camel TypeConverter to do the String to DateFromat converter (CxfConverter.toDataFormat()). You just need to define a DataFromat member in the Endpoint and provides get and set method for it. DefaultEndpoint will use the IntrospectionSupport to load the convertor automatically when it set the Properties. > > >> By analysing the code, I have discovered that the method : receive as >> parameter the quickFix.Message >> >> What is the best approach to implement this in the endpoint ? >> >> 1) Create 2 createExchange(Message message) createExchange(String string) >> >> or change the existing to let the consumer/producer to return a >> String/Message/XML/.... >> >> Here is a snapshot of the code : >> >> public void onMessage(Message message) { >> Exchange exchange = createExchange(message); >> try { >> processor.process(exchange); >> } catch (Exception e) { >> exchange.setException(e); >> } >> >> } >> >> public Exchange createExchange(Message message) { >> setExchangePattern(ExchangePattern.InOut); >> Exchange answer = createExchange(); >> answer.getIn().setBody(message); >> answer.getOut().setBody(message); >> return answer; > Here is a good spot. You can usually get the endpoint and ask which > dataFormat it was configued with. > Then you know if its a String or QuickFix message you should set as Body. > > But why are you setting both the IN and OUT to the same message? > Usually it is only IN you set. > > Yes, we just need to set the In message for it. I will did a quick fix for it. >> } >> >> // for initiator >> public Producer createProducer() throws Exception { >> return new QuickfixProducer(this); >> } >> >> // for acceptor >> public Consumer createConsumer(Processor processor) throws Exception { >> this.processor = processor; >> return new QuickfixConsumer(this, processor); >> } >> >> Regards, >> >> Charles Moulliard >> Senior Enterprise Architect >> Apache Camel Committer >> >> ***************************** >> blog : http://cmoulliard.blogspot.com >> > > > Willem
