Hi,
I am trying to convert a model object into FIX message using Bindy.
I am passing the List object of the model class(purchase_order) and getting
the following
*output :
1=Camel in Action|3=19|4=40| *
Here it is like* tag=value*, I need it as *Key(field name)=value*.
What should I do for that
here is my *purchase_order class*:
package CamelBindy.Test;
import java.math.BigDecimal;
import org.apache.camel.dataformat.bindy.annotation.KeyValuePairField;
import org.apache.camel.dataformat.bindy.annotation.Link;
import org.apache.camel.dataformat.bindy.annotation.Message;
import org.apache.camel.dataformat.bindy.annotation.Section;
//@CsvRecord(separator = ",", crlf = "UNIX")
@Section(number = 2)
@Message(keyValuePairSeparator = "=", pairSeparator = "||", type = "FIX",
version = "4.1")
public class Purchase_order
{
@Link Header header;
@Link Trailer trailer;
@KeyValuePairField(tag=1)
private String name;
@KeyValuePairField(tag = 4)
private BigDecimal price;
@KeyValuePairField(tag = 3)
private int amount;
getters() & setters()
}
*Camelclass:*package CamelBindy.Test;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.dataformat.BindyType;
public class BindyTest
{
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
final List<Map<String, Object>> obj = new
ArrayList<Map<String,
Object>>();
Map<String, Object> model = new HashMap<String,
Object>();
Purchase_order order = new Purchase_order();
order.setAmount(19);
order.setPrice(new BigDecimal("39.95"));
order.setName("Camel in Action");
model.put(order.getClass().getName(), order);
obj.add(0, model);
context.addRoutes(new RouteBuilder() {
@Override
public void configure()
{
from("direct:toCsv").marshal().bindy(BindyType.KeyValue,"CamelBindy.Test")
.to("file://test4?fileName=mano.txt");
}
});
ProducerTemplate template =
context.createProducerTemplate();
context.start();
template.sendBody("direct:toCsv",obj);
Thread.sleep(1000);
context.stop();
}
}
--
View this message in context:
http://camel.465427.n5.nabble.com/Key-field-name-required-instead-of-Tag-number-tp5743021.html
Sent from the Camel - Users mailing list archive at Nabble.com.