You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Pablo Venini <pv...@mervaros.com.ar> on 2011/06/15 21:29:58 UTC

Translate FIX message to HTTP request

Hi, I'm trying to build a translator that processes FIX messages and
translate the parameters into the query string of a HTTP request. I'am using
bindy but I don't seem to get the hang of it.
I created a route and three model classes:

package gateway;
public class MyRouteBuilder extends RouteBuilder {
    public void configure() {
    	BindyKeyValuePairDataFormat camelDataFormat = new  
BindyKeyValuePairDataFormat("gateway.model");
        
    	from("quickfix:config.cfg").
    	choice().
    	
when(header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.ORDER_SINGLE)).
          		unmarshal(camelDataFormat).
          		to("http4://www.server.com").
    		otherwise().
    		    to("log:localhost");
    }
}


package gateway.model;
@Message(keyValuePairSeparator = "=", pairSeparator = "\\u0001", type =
"FIX", version = "4.4")
public class Order{
    @Link
    Header header;

    @Link
    Trailer trailer;

    @KeyValuePairField(tag = 1)
    // Client reference
    private String account;

    @KeyValuePairField(tag = 11)
    // Order reference
    private String clOrdId;

    @KeyValuePairField(tag = 22)
    // Fund ID type (Sedol, ISIN, ...)
    private String iDSource;

    @KeyValuePairField(tag = 48)
    // Fund code
    private String securityId;

    @KeyValuePairField(tag = 54)
    // Movement type ( 1 = Buy, 2 = sell)
    private String side;

    @KeyValuePairField(tag = 58)
    // Free text
    private String text;

    public Header getHeader() {
        return header;
    }

    public void setHeader(Header header) {
        this.header = header;
    }

    public Trailer getTrailer() {
        return trailer;
    }

    public void setTrailer(Trailer trailer) {
        this.trailer = trailer;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getClOrdId() {
        return clOrdId;
    }

    public void setClOrdId(String clOrdId) {
        this.clOrdId = clOrdId;
    }

    public String getIDSource() {
        return iDSource;
    }

    public void setIDSource(String source) {
        this.iDSource = source;
    }

    public String getSecurityId() {
        return securityId;
    }

    public void setSecurityId(String securityId) {
        this.securityId = securityId;
    }

    public String getSide() {
        return side;
    }

    public void setSide(String side) {
        this.side = side;
    }

    public String getText() {
        return this.text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Override
    public String toString() {
        return Order.class.getName() + " --> 1: " + this.account + ", 11: "
+ this.clOrdId + ", 22: " + this.iDSource + ", 48: " + this.securityId + ",
54: " + this.side
               + ", 58: " + this.text;
    }
}


package gateway.model;
@Link
public class Header{
    @KeyValuePairField(tag = 8)
    // Message Header
    private String beginString;

    @KeyValuePairField(tag = 9)
    // Checksum
    private int bodyLength;

    @KeyValuePairField(tag = 34)
    // Sequence number
    private int msgSeqNum;

    @KeyValuePairField(tag = 35)
    // Message Type
    private String msgType;

    @KeyValuePairField(tag = 49)
    // Company sender Id
    private String sendCompId;

    @KeyValuePairField(tag = 56)
    // target company id
    private String targetCompId;

    public String getBeginString() {
        return beginString;
    }

    public void setBeginString(String beginString) {
        this.beginString = beginString;
    }

    public int getBodyLength() {
        return bodyLength;
    }

    public void setBodyLength(int bodyLength) {
        this.bodyLength = bodyLength;
    }

    public int getMsgSeqNum() {
        return msgSeqNum;
    }

    public void setMsgSeqNum(int msgSeqNum) {
        this.msgSeqNum = msgSeqNum;
    }

    public String getMsgType() {
        return msgType;
    }

    public void setMsgType(String msgType) {
        this.msgType = msgType;
    }

    public String getSendCompId() {
        return sendCompId;
    }

    public void setSendCompId(String sendCompId) {
        this.sendCompId = sendCompId;
    }

    public String getTargetCompId() {
        return targetCompId;
    }

    public void setTargetCompId(String targetCompId) {
        this.targetCompId = targetCompId;
    }

    @Override
    public String toString() {
        return Header.class.getName() + " --> 8: " + this.beginString + ",
9: " + this.bodyLength + ", 34: " + this.msgSeqNum + " , 35: " +
this.msgType + ", 49: "
               + this.sendCompId + ", 56: " + this.targetCompId;
    }
}




package gateway.model;
@Link
public class Trailer{
    @KeyValuePairField(tag = 10)
    // CheckSum
    private int checkSum;

    public int getCheckSum() {
        return checkSum;
    }

    public void setCheckSum(int checkSum) {
        this.checkSum = checkSum;
    }

    @Override
    public String toString() {
        return Trailer.class.getName() + " --> 10: " + this.checkSum;
    }
}



Whenever I run the example and I receive a new order, I get an exception

[         QFJ Message Processor] DefaultErrorHandler            ERROR Failed
delivery for exchangeId: ID-Sinac-3-4710-1308159740143-0-6. Exhausted after
delivery attempt: 1 caught: org.apache.camel.InvalidPayloadException: No
body available of type: java.io.InputStream but has value: 8=FIX.4.4..... of
type: quickfix.fix44.NewOrderSingle on: Message: 8=FIX.4.4.... Caused by: No
type converter available to convert from type: quickfix.fix44.NewOrderSingle
to the required type: java.io.InputStream with value 8=FIX.4.4....
Exchange[Message: 8=FIX.4.4...]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type: quickfix.fix44.NewOrderSingle to the
required type: java.io.InputStream with value 


I don't quite get what I must do to perform the translation.

Any pointers would be appreciated

Pablo



Re: Re: Translate FIX message to HTTP request

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jul 18, 2011 at 4:05 PM, pvenini <pv...@mervaros.com.ar> wrote:
> Hi, I finally managed to go forward a few steps by modifying the quickfix
> converter. The route I'm building looks like this:
>
> from("quickfix:config.cfg").
> filter(
>
> header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.ORDER_SINGLE)).
> unmarshal(camelDataFormat).
> to("jetty:http://localhost:8502/trade.php").
> process(new HttpResponseProcessor()).
> marshal(camelDataFormat).
> to("quickfix:config.cfg");
>
> The idea is that the FIX NewOrderSingle message is parsed by Bindy, an HTTP
> request is generated an sent to the destination server and depending on the
> response, a FIX message is sent back (an ExecutionReport).
> This works OK up to the point of the marshal part, but when it gets to the
> to:quickfix.cfg (the final destination in the route), the inMessage reverts
> to the original NewOrderSingle message, an the Quickfix component throws a
> null pointer exception.
> Question is: is this route correct (I'm using the same endpoint for the
> consumer and the producer) and if not, what should be the correct way to
> send the response back?
>

It depends on the consumer. Some supports a request/response pattern.
For example a web server, where a HTTP client send a request to the
web server, and the web server sends back a response.

The FIX consumer may support that as well, if a client is to do a request/reply.
In those cases you just do

from X
  filter
  to Y
  marshal
  to Z

So the idiom is that when the route "ends" then the consumer gets
control back and can send back the reply message, based on what the
message currently has been set as.



> Thanks
>
> Pablo
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Translate-FIX-message-to-HTTP-request-tp4492401p4599664.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Re: Translate FIX message to HTTP request

Posted by pvenini <pv...@mervaros.com.ar>.
Hi, I created CAMEL-4278. It adds one method to convert from byte[] to
Message, and one to convert from quickfixj.Message to InputStream. I had to
add them both to be able to marshal/unmarshal quickfixj messages with Bindy.

Pablo

--
View this message in context: http://camel.465427.n5.nabble.com/Translate-FIX-message-to-HTTP-request-tp4492401p4644392.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Re: Translate FIX message to HTTP request

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jul 21, 2011 at 11:08 PM, pvenini <pv...@mervaros.com.ar> wrote:
> I solved the problem adding a type converter from byte array (the result of
> Bindy's marshal) to quickfix Message. The QuickFixConverter that cames with
> the examples has a method to convert from String to quickfix Message so it
> wasn't used.
>

Fell free to contribute a byte[] -> quickfix message converter. Then
we can include that in the component out of the box.
http://camel.apache.org/contributing.html

> --
> View this message in context: http://camel.465427.n5.nabble.com/Translate-FIX-message-to-HTTP-request-tp4492401p4621016.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Re: Translate FIX message to HTTP request

Posted by pvenini <pv...@mervaros.com.ar>.
I solved the problem adding a type converter from byte array (the result of
Bindy's marshal) to quickfix Message. The QuickFixConverter that cames with
the examples has a method to convert from String to quickfix Message so it
wasn't used.

--
View this message in context: http://camel.465427.n5.nabble.com/Translate-FIX-message-to-HTTP-request-tp4492401p4621016.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Re: Translate FIX message to HTTP request

Posted by vcheruvu <v_...@hotmail.com>.
would you mind showing the  details of config.cfg. I believe there is some
config issue in your end  that you need to specify somethig like below
statement. Also, If you can show me the stack trace of your null pointer,
then it could help me to see where and how you are experiencing the issue.

to("quickfix:config.cfg?sessionID=FIX.4.2:SENDERCOMPID->TARGETCOMPID")


kind regards,
-Vid-

--
View this message in context: http://camel.465427.n5.nabble.com/Translate-FIX-message-to-HTTP-request-tp4492401p4613914.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Re: Translate FIX message to HTTP request

Posted by pvenini <pv...@mervaros.com.ar>.
Hi, I finally managed to go forward a few steps by modifying the quickfix
converter. The route I'm building looks like this:

from("quickfix:config.cfg").
filter(   	
 
header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.ORDER_SINGLE)).
unmarshal(camelDataFormat).
to("jetty:http://localhost:8502/trade.php").
process(new HttpResponseProcessor()).
marshal(camelDataFormat).
to("quickfix:config.cfg"); 

The idea is that the FIX NewOrderSingle message is parsed by Bindy, an HTTP
request is generated an sent to the destination server and depending on the
response, a FIX message is sent back (an ExecutionReport). 
This works OK up to the point of the marshal part, but when it gets to the
to:quickfix.cfg (the final destination in the route), the inMessage reverts
to the original NewOrderSingle message, an the Quickfix component throws a
null pointer exception.
Question is: is this route correct (I'm using the same endpoint for the
consumer and the producer) and if not, what should be the correct way to
send the response back?

Thanks

Pablo

--
View this message in context: http://camel.465427.n5.nabble.com/Translate-FIX-message-to-HTTP-request-tp4492401p4599664.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Re: Translate FIX message to HTTP request

Posted by Pablo Venini <pv...@mervaros.com.ar>.
Richard:
            thanks for your reply, I'm using Camel 2.7.2. Is  the 
converter in 2.5.0 usable in a 2.7.0 environment or should I 
downgrade/modify it?.
Another question: is bindy the way to go in this case (I thought so 
because of the annotations geared toward FIX use) or should I chose a 
different alternative?

Pablo


Richard Kettelerij escribió:
> The quickfix component was rewritten as part of Camel 2.5, what Camel
> version are you using? Prior to the rewrite the quickfix component did
> contain a simple converter to convert quickfix messages to inputstreams.
>
> On Wed, Jun 15, 2011 at 10:43 PM, Richard Kettelerij <
> richardkettelerij@gmail.com> wrote:
>
>   
>> Since your going from Quickfix to Bindy you have an Exchange which contains
>> a Quickfix message (specifically quickfix.fix44.NewOrderSingle) as its body.
>> The bindy component expects a Java inputstream. However, there's no
>> converter available to translate Quickfix messages to inputstreams.
>>
>> You might be able to write such a converter. Otherwise take a look at the
>> quickfix unit tests to see how these messages are handled.
>>
>>
>> On Wed, Jun 15, 2011 at 9:29 PM, Pablo Venini <pv...@mervaros.com.ar>wrote:
>>
>>     
>>> Hi, I'm trying to build a translator that processes FIX messages and
>>> translate the parameters into the query string of a HTTP request. I'am
>>> using
>>> bindy but I don't seem to get the hang of it.
>>> I created a route and three model classes:
>>>
>>> package gateway;
>>> public class MyRouteBuilder extends RouteBuilder {
>>>   public void configure() {
>>>        BindyKeyValuePairDataFormat camelDataFormat = new
>>>  BindyKeyValuePairDataFormat("gateway.model");
>>>                from("quickfix:config.cfg").
>>>        choice().
>>>
>>>
>>> when(header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.ORDER_SINGLE)).
>>>                        unmarshal(camelDataFormat).
>>>                        to("http4://www.server.com").
>>>                otherwise().
>>>                    to("log:localhost");
>>>   }
>>> }
>>>
>>>
>>> package gateway.model;
>>> @Message(keyValuePairSeparator = "=", pairSeparator = "\\u0001", type =
>>> "FIX", version = "4.4")
>>> public class Order{
>>>   @Link
>>>   Header header;
>>>
>>>   @Link
>>>   Trailer trailer;
>>>
>>>   @KeyValuePairField(tag = 1)
>>>   // Client reference
>>>   private String account;
>>>
>>>   @KeyValuePairField(tag = 11)
>>>   // Order reference
>>>   private String clOrdId;
>>>
>>>   @KeyValuePairField(tag = 22)
>>>   // Fund ID type (Sedol, ISIN, ...)
>>>   private String iDSource;
>>>
>>>   @KeyValuePairField(tag = 48)
>>>   // Fund code
>>>   private String securityId;
>>>
>>>   @KeyValuePairField(tag = 54)
>>>   // Movement type ( 1 = Buy, 2 = sell)
>>>   private String side;
>>>
>>>   @KeyValuePairField(tag = 58)
>>>   // Free text
>>>   private String text;
>>>
>>>   public Header getHeader() {
>>>       return header;
>>>   }
>>>
>>>   public void setHeader(Header header) {
>>>       this.header = header;
>>>   }
>>>
>>>   public Trailer getTrailer() {
>>>       return trailer;
>>>   }
>>>
>>>   public void setTrailer(Trailer trailer) {
>>>       this.trailer = trailer;
>>>   }
>>>
>>>   public String getAccount() {
>>>       return account;
>>>   }
>>>
>>>   public void setAccount(String account) {
>>>       this.account = account;
>>>   }
>>>
>>>   public String getClOrdId() {
>>>       return clOrdId;
>>>   }
>>>
>>>   public void setClOrdId(String clOrdId) {
>>>       this.clOrdId = clOrdId;
>>>   }
>>>
>>>   public String getIDSource() {
>>>       return iDSource;
>>>   }
>>>
>>>   public void setIDSource(String source) {
>>>       this.iDSource = source;
>>>   }
>>>
>>>   public String getSecurityId() {
>>>       return securityId;
>>>   }
>>>
>>>   public void setSecurityId(String securityId) {
>>>       this.securityId = securityId;
>>>   }
>>>
>>>   public String getSide() {
>>>       return side;
>>>   }
>>>
>>>   public void setSide(String side) {
>>>       this.side = side;
>>>   }
>>>
>>>   public String getText() {
>>>       return this.text;
>>>   }
>>>
>>>   public void setText(String text) {
>>>       this.text = text;
>>>   }
>>>
>>>   @Override
>>>   public String toString() {
>>>       return Order.class.getName() + " --> 1: " + this.account + ", 11: "
>>> + this.clOrdId + ", 22: " + this.iDSource + ", 48: " + this.securityId +
>>> ",
>>> 54: " + this.side
>>>              + ", 58: " + this.text;
>>>   }
>>> }
>>>
>>>
>>> package gateway.model;
>>> @Link
>>> public class Header{
>>>   @KeyValuePairField(tag = 8)
>>>   // Message Header
>>>   private String beginString;
>>>
>>>   @KeyValuePairField(tag = 9)
>>>   // Checksum
>>>   private int bodyLength;
>>>
>>>   @KeyValuePairField(tag = 34)
>>>   // Sequence number
>>>   private int msgSeqNum;
>>>
>>>   @KeyValuePairField(tag = 35)
>>>   // Message Type
>>>   private String msgType;
>>>
>>>   @KeyValuePairField(tag = 49)
>>>   // Company sender Id
>>>   private String sendCompId;
>>>
>>>   @KeyValuePairField(tag = 56)
>>>   // target company id
>>>   private String targetCompId;
>>>
>>>   public String getBeginString() {
>>>       return beginString;
>>>   }
>>>
>>>   public void setBeginString(String beginString) {
>>>       this.beginString = beginString;
>>>   }
>>>
>>>   public int getBodyLength() {
>>>       return bodyLength;
>>>   }
>>>
>>>   public void setBodyLength(int bodyLength) {
>>>       this.bodyLength = bodyLength;
>>>   }
>>>
>>>   public int getMsgSeqNum() {
>>>       return msgSeqNum;
>>>   }
>>>
>>>   public void setMsgSeqNum(int msgSeqNum) {
>>>       this.msgSeqNum = msgSeqNum;
>>>   }
>>>
>>>   public String getMsgType() {
>>>       return msgType;
>>>   }
>>>
>>>   public void setMsgType(String msgType) {
>>>       this.msgType = msgType;
>>>   }
>>>
>>>   public String getSendCompId() {
>>>       return sendCompId;
>>>   }
>>>
>>>   public void setSendCompId(String sendCompId) {
>>>       this.sendCompId = sendCompId;
>>>   }
>>>
>>>   public String getTargetCompId() {
>>>       return targetCompId;
>>>   }
>>>
>>>   public void setTargetCompId(String targetCompId) {
>>>       this.targetCompId = targetCompId;
>>>   }
>>>
>>>   @Override
>>>   public String toString() {
>>>       return Header.class.getName() + " --> 8: " + this.beginString + ",
>>> 9: " + this.bodyLength + ", 34: " + this.msgSeqNum + " , 35: " +
>>> this.msgType + ", 49: "
>>>              + this.sendCompId + ", 56: " + this.targetCompId;
>>>   }
>>> }
>>>
>>>
>>>
>>>
>>> package gateway.model;
>>> @Link
>>> public class Trailer{
>>>   @KeyValuePairField(tag = 10)
>>>   // CheckSum
>>>   private int checkSum;
>>>
>>>   public int getCheckSum() {
>>>       return checkSum;
>>>   }
>>>
>>>   public void setCheckSum(int checkSum) {
>>>       this.checkSum = checkSum;
>>>   }
>>>
>>>   @Override
>>>   public String toString() {
>>>       return Trailer.class.getName() + " --> 10: " + this.checkSum;
>>>   }
>>> }
>>>
>>>
>>>
>>> Whenever I run the example and I receive a new order, I get an exception
>>>
>>> [         QFJ Message Processor] DefaultErrorHandler            ERROR
>>> Failed
>>> delivery for exchangeId: ID-Sinac-3-4710-1308159740143-0-6. Exhausted
>>> after
>>> delivery attempt: 1 caught: org.apache.camel.InvalidPayloadException: No
>>> body available of type: java.io.InputStream but has value: 8=FIX.4.4.....
>>> of
>>> type: quickfix.fix44.NewOrderSingle on: Message: 8=FIX.4.4.... Caused by:
>>> No
>>> type converter available to convert from type:
>>> quickfix.fix44.NewOrderSingle
>>> to the required type: java.io.InputStream with value 8=FIX.4.4....
>>> Exchange[Message: 8=FIX.4.4...]. Caused by:
>>> [org.apache.camel.NoTypeConversionAvailableException - No type converter
>>> available to convert from type: quickfix.fix44.NewOrderSingle to the
>>> required type: java.io.InputStream with value
>>>
>>> I don't quite get what I must do to perform the translation.
>>>
>>> Any pointers would be appreciated
>>>
>>> Pablo
>>>
>>>
>>>
>>>       
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature database 6211 (20110615) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>   

-- 
/*Ing. Pablo Venini*/

/*Area Sistemas*/

/*Mercado de Valores de Rosario S.A.*/

/*(2000) Rosario - Santa Fe - Argentina*/

*TE: 0341 - 421-0125/424-7879 Int. 143*


Re: Translate FIX message to HTTP request

Posted by Richard Kettelerij <ri...@gmail.com>.
The quickfix component was rewritten as part of Camel 2.5, what Camel
version are you using? Prior to the rewrite the quickfix component did
contain a simple converter to convert quickfix messages to inputstreams.

On Wed, Jun 15, 2011 at 10:43 PM, Richard Kettelerij <
richardkettelerij@gmail.com> wrote:

> Since your going from Quickfix to Bindy you have an Exchange which contains
> a Quickfix message (specifically quickfix.fix44.NewOrderSingle) as its body.
> The bindy component expects a Java inputstream. However, there's no
> converter available to translate Quickfix messages to inputstreams.
>
> You might be able to write such a converter. Otherwise take a look at the
> quickfix unit tests to see how these messages are handled.
>
>
> On Wed, Jun 15, 2011 at 9:29 PM, Pablo Venini <pv...@mervaros.com.ar>wrote:
>
>> Hi, I'm trying to build a translator that processes FIX messages and
>> translate the parameters into the query string of a HTTP request. I'am
>> using
>> bindy but I don't seem to get the hang of it.
>> I created a route and three model classes:
>>
>> package gateway;
>> public class MyRouteBuilder extends RouteBuilder {
>>   public void configure() {
>>        BindyKeyValuePairDataFormat camelDataFormat = new
>>  BindyKeyValuePairDataFormat("gateway.model");
>>                from("quickfix:config.cfg").
>>        choice().
>>
>>
>> when(header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.ORDER_SINGLE)).
>>                        unmarshal(camelDataFormat).
>>                        to("http4://www.server.com").
>>                otherwise().
>>                    to("log:localhost");
>>   }
>> }
>>
>>
>> package gateway.model;
>> @Message(keyValuePairSeparator = "=", pairSeparator = "\\u0001", type =
>> "FIX", version = "4.4")
>> public class Order{
>>   @Link
>>   Header header;
>>
>>   @Link
>>   Trailer trailer;
>>
>>   @KeyValuePairField(tag = 1)
>>   // Client reference
>>   private String account;
>>
>>   @KeyValuePairField(tag = 11)
>>   // Order reference
>>   private String clOrdId;
>>
>>   @KeyValuePairField(tag = 22)
>>   // Fund ID type (Sedol, ISIN, ...)
>>   private String iDSource;
>>
>>   @KeyValuePairField(tag = 48)
>>   // Fund code
>>   private String securityId;
>>
>>   @KeyValuePairField(tag = 54)
>>   // Movement type ( 1 = Buy, 2 = sell)
>>   private String side;
>>
>>   @KeyValuePairField(tag = 58)
>>   // Free text
>>   private String text;
>>
>>   public Header getHeader() {
>>       return header;
>>   }
>>
>>   public void setHeader(Header header) {
>>       this.header = header;
>>   }
>>
>>   public Trailer getTrailer() {
>>       return trailer;
>>   }
>>
>>   public void setTrailer(Trailer trailer) {
>>       this.trailer = trailer;
>>   }
>>
>>   public String getAccount() {
>>       return account;
>>   }
>>
>>   public void setAccount(String account) {
>>       this.account = account;
>>   }
>>
>>   public String getClOrdId() {
>>       return clOrdId;
>>   }
>>
>>   public void setClOrdId(String clOrdId) {
>>       this.clOrdId = clOrdId;
>>   }
>>
>>   public String getIDSource() {
>>       return iDSource;
>>   }
>>
>>   public void setIDSource(String source) {
>>       this.iDSource = source;
>>   }
>>
>>   public String getSecurityId() {
>>       return securityId;
>>   }
>>
>>   public void setSecurityId(String securityId) {
>>       this.securityId = securityId;
>>   }
>>
>>   public String getSide() {
>>       return side;
>>   }
>>
>>   public void setSide(String side) {
>>       this.side = side;
>>   }
>>
>>   public String getText() {
>>       return this.text;
>>   }
>>
>>   public void setText(String text) {
>>       this.text = text;
>>   }
>>
>>   @Override
>>   public String toString() {
>>       return Order.class.getName() + " --> 1: " + this.account + ", 11: "
>> + this.clOrdId + ", 22: " + this.iDSource + ", 48: " + this.securityId +
>> ",
>> 54: " + this.side
>>              + ", 58: " + this.text;
>>   }
>> }
>>
>>
>> package gateway.model;
>> @Link
>> public class Header{
>>   @KeyValuePairField(tag = 8)
>>   // Message Header
>>   private String beginString;
>>
>>   @KeyValuePairField(tag = 9)
>>   // Checksum
>>   private int bodyLength;
>>
>>   @KeyValuePairField(tag = 34)
>>   // Sequence number
>>   private int msgSeqNum;
>>
>>   @KeyValuePairField(tag = 35)
>>   // Message Type
>>   private String msgType;
>>
>>   @KeyValuePairField(tag = 49)
>>   // Company sender Id
>>   private String sendCompId;
>>
>>   @KeyValuePairField(tag = 56)
>>   // target company id
>>   private String targetCompId;
>>
>>   public String getBeginString() {
>>       return beginString;
>>   }
>>
>>   public void setBeginString(String beginString) {
>>       this.beginString = beginString;
>>   }
>>
>>   public int getBodyLength() {
>>       return bodyLength;
>>   }
>>
>>   public void setBodyLength(int bodyLength) {
>>       this.bodyLength = bodyLength;
>>   }
>>
>>   public int getMsgSeqNum() {
>>       return msgSeqNum;
>>   }
>>
>>   public void setMsgSeqNum(int msgSeqNum) {
>>       this.msgSeqNum = msgSeqNum;
>>   }
>>
>>   public String getMsgType() {
>>       return msgType;
>>   }
>>
>>   public void setMsgType(String msgType) {
>>       this.msgType = msgType;
>>   }
>>
>>   public String getSendCompId() {
>>       return sendCompId;
>>   }
>>
>>   public void setSendCompId(String sendCompId) {
>>       this.sendCompId = sendCompId;
>>   }
>>
>>   public String getTargetCompId() {
>>       return targetCompId;
>>   }
>>
>>   public void setTargetCompId(String targetCompId) {
>>       this.targetCompId = targetCompId;
>>   }
>>
>>   @Override
>>   public String toString() {
>>       return Header.class.getName() + " --> 8: " + this.beginString + ",
>> 9: " + this.bodyLength + ", 34: " + this.msgSeqNum + " , 35: " +
>> this.msgType + ", 49: "
>>              + this.sendCompId + ", 56: " + this.targetCompId;
>>   }
>> }
>>
>>
>>
>>
>> package gateway.model;
>> @Link
>> public class Trailer{
>>   @KeyValuePairField(tag = 10)
>>   // CheckSum
>>   private int checkSum;
>>
>>   public int getCheckSum() {
>>       return checkSum;
>>   }
>>
>>   public void setCheckSum(int checkSum) {
>>       this.checkSum = checkSum;
>>   }
>>
>>   @Override
>>   public String toString() {
>>       return Trailer.class.getName() + " --> 10: " + this.checkSum;
>>   }
>> }
>>
>>
>>
>> Whenever I run the example and I receive a new order, I get an exception
>>
>> [         QFJ Message Processor] DefaultErrorHandler            ERROR
>> Failed
>> delivery for exchangeId: ID-Sinac-3-4710-1308159740143-0-6. Exhausted
>> after
>> delivery attempt: 1 caught: org.apache.camel.InvalidPayloadException: No
>> body available of type: java.io.InputStream but has value: 8=FIX.4.4.....
>> of
>> type: quickfix.fix44.NewOrderSingle on: Message: 8=FIX.4.4.... Caused by:
>> No
>> type converter available to convert from type:
>> quickfix.fix44.NewOrderSingle
>> to the required type: java.io.InputStream with value 8=FIX.4.4....
>> Exchange[Message: 8=FIX.4.4...]. Caused by:
>> [org.apache.camel.NoTypeConversionAvailableException - No type converter
>> available to convert from type: quickfix.fix44.NewOrderSingle to the
>> required type: java.io.InputStream with value
>>
>> I don't quite get what I must do to perform the translation.
>>
>> Any pointers would be appreciated
>>
>> Pablo
>>
>>
>>
>

Re: Translate FIX message to HTTP request

Posted by Richard Kettelerij <ri...@gmail.com>.
Since your going from Quickfix to Bindy you have an Exchange which contains
a Quickfix message (specifically quickfix.fix44.NewOrderSingle) as its body.
The bindy component expects a Java inputstream. However, there's no
converter available to translate Quickfix messages to inputstreams.

You might be able to write such a converter. Otherwise take a look at the
quickfix unit tests to see how these messages are handled.

On Wed, Jun 15, 2011 at 9:29 PM, Pablo Venini <pv...@mervaros.com.ar>wrote:

> Hi, I'm trying to build a translator that processes FIX messages and
> translate the parameters into the query string of a HTTP request. I'am
> using
> bindy but I don't seem to get the hang of it.
> I created a route and three model classes:
>
> package gateway;
> public class MyRouteBuilder extends RouteBuilder {
>   public void configure() {
>        BindyKeyValuePairDataFormat camelDataFormat = new
>  BindyKeyValuePairDataFormat("gateway.model");
>                from("quickfix:config.cfg").
>        choice().
>
>
> when(header(QuickfixjEndpoint.MESSAGE_TYPE_KEY).isEqualTo(MsgType.ORDER_SINGLE)).
>                        unmarshal(camelDataFormat).
>                        to("http4://www.server.com").
>                otherwise().
>                    to("log:localhost");
>   }
> }
>
>
> package gateway.model;
> @Message(keyValuePairSeparator = "=", pairSeparator = "\\u0001", type =
> "FIX", version = "4.4")
> public class Order{
>   @Link
>   Header header;
>
>   @Link
>   Trailer trailer;
>
>   @KeyValuePairField(tag = 1)
>   // Client reference
>   private String account;
>
>   @KeyValuePairField(tag = 11)
>   // Order reference
>   private String clOrdId;
>
>   @KeyValuePairField(tag = 22)
>   // Fund ID type (Sedol, ISIN, ...)
>   private String iDSource;
>
>   @KeyValuePairField(tag = 48)
>   // Fund code
>   private String securityId;
>
>   @KeyValuePairField(tag = 54)
>   // Movement type ( 1 = Buy, 2 = sell)
>   private String side;
>
>   @KeyValuePairField(tag = 58)
>   // Free text
>   private String text;
>
>   public Header getHeader() {
>       return header;
>   }
>
>   public void setHeader(Header header) {
>       this.header = header;
>   }
>
>   public Trailer getTrailer() {
>       return trailer;
>   }
>
>   public void setTrailer(Trailer trailer) {
>       this.trailer = trailer;
>   }
>
>   public String getAccount() {
>       return account;
>   }
>
>   public void setAccount(String account) {
>       this.account = account;
>   }
>
>   public String getClOrdId() {
>       return clOrdId;
>   }
>
>   public void setClOrdId(String clOrdId) {
>       this.clOrdId = clOrdId;
>   }
>
>   public String getIDSource() {
>       return iDSource;
>   }
>
>   public void setIDSource(String source) {
>       this.iDSource = source;
>   }
>
>   public String getSecurityId() {
>       return securityId;
>   }
>
>   public void setSecurityId(String securityId) {
>       this.securityId = securityId;
>   }
>
>   public String getSide() {
>       return side;
>   }
>
>   public void setSide(String side) {
>       this.side = side;
>   }
>
>   public String getText() {
>       return this.text;
>   }
>
>   public void setText(String text) {
>       this.text = text;
>   }
>
>   @Override
>   public String toString() {
>       return Order.class.getName() + " --> 1: " + this.account + ", 11: "
> + this.clOrdId + ", 22: " + this.iDSource + ", 48: " + this.securityId + ",
> 54: " + this.side
>              + ", 58: " + this.text;
>   }
> }
>
>
> package gateway.model;
> @Link
> public class Header{
>   @KeyValuePairField(tag = 8)
>   // Message Header
>   private String beginString;
>
>   @KeyValuePairField(tag = 9)
>   // Checksum
>   private int bodyLength;
>
>   @KeyValuePairField(tag = 34)
>   // Sequence number
>   private int msgSeqNum;
>
>   @KeyValuePairField(tag = 35)
>   // Message Type
>   private String msgType;
>
>   @KeyValuePairField(tag = 49)
>   // Company sender Id
>   private String sendCompId;
>
>   @KeyValuePairField(tag = 56)
>   // target company id
>   private String targetCompId;
>
>   public String getBeginString() {
>       return beginString;
>   }
>
>   public void setBeginString(String beginString) {
>       this.beginString = beginString;
>   }
>
>   public int getBodyLength() {
>       return bodyLength;
>   }
>
>   public void setBodyLength(int bodyLength) {
>       this.bodyLength = bodyLength;
>   }
>
>   public int getMsgSeqNum() {
>       return msgSeqNum;
>   }
>
>   public void setMsgSeqNum(int msgSeqNum) {
>       this.msgSeqNum = msgSeqNum;
>   }
>
>   public String getMsgType() {
>       return msgType;
>   }
>
>   public void setMsgType(String msgType) {
>       this.msgType = msgType;
>   }
>
>   public String getSendCompId() {
>       return sendCompId;
>   }
>
>   public void setSendCompId(String sendCompId) {
>       this.sendCompId = sendCompId;
>   }
>
>   public String getTargetCompId() {
>       return targetCompId;
>   }
>
>   public void setTargetCompId(String targetCompId) {
>       this.targetCompId = targetCompId;
>   }
>
>   @Override
>   public String toString() {
>       return Header.class.getName() + " --> 8: " + this.beginString + ",
> 9: " + this.bodyLength + ", 34: " + this.msgSeqNum + " , 35: " +
> this.msgType + ", 49: "
>              + this.sendCompId + ", 56: " + this.targetCompId;
>   }
> }
>
>
>
>
> package gateway.model;
> @Link
> public class Trailer{
>   @KeyValuePairField(tag = 10)
>   // CheckSum
>   private int checkSum;
>
>   public int getCheckSum() {
>       return checkSum;
>   }
>
>   public void setCheckSum(int checkSum) {
>       this.checkSum = checkSum;
>   }
>
>   @Override
>   public String toString() {
>       return Trailer.class.getName() + " --> 10: " + this.checkSum;
>   }
> }
>
>
>
> Whenever I run the example and I receive a new order, I get an exception
>
> [         QFJ Message Processor] DefaultErrorHandler            ERROR
> Failed
> delivery for exchangeId: ID-Sinac-3-4710-1308159740143-0-6. Exhausted after
> delivery attempt: 1 caught: org.apache.camel.InvalidPayloadException: No
> body available of type: java.io.InputStream but has value: 8=FIX.4.4.....
> of
> type: quickfix.fix44.NewOrderSingle on: Message: 8=FIX.4.4.... Caused by:
> No
> type converter available to convert from type:
> quickfix.fix44.NewOrderSingle
> to the required type: java.io.InputStream with value 8=FIX.4.4....
> Exchange[Message: 8=FIX.4.4...]. Caused by:
> [org.apache.camel.NoTypeConversionAvailableException - No type converter
> available to convert from type: quickfix.fix44.NewOrderSingle to the
> required type: java.io.InputStream with value
>
> I don't quite get what I must do to perform the translation.
>
> Any pointers would be appreciated
>
> Pablo
>
>
>