camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pablo Venini <pven...@mervaros.com.ar>
Subject Translate FIX message to HTTP request
Date Wed, 15 Jun 2011 19:29:58 GMT
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



Mime
View raw message