camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manoranjitham G <manoranjitha...@polarisft.com>
Subject Model object into FIX message conversion using Bindy
Date Mon, 11 Nov 2013 09:10:10 GMT
Hi,

I am trying to convert a model object into a FIX message using Bindy
dataformat.


This is my code:
 
Purchase_order Model class:

package CamelBindy.Test;

import java.math.BigDecimal;
import org.apache.camel.dataformat.bindy.annotation.DataField;
import org.apache.camel.dataformat.bindy.annotation.Message;

@Message(keyValuePairSeparator = "=", pairSeparator = "\\u0001", type =
"FIX", version = "4.1", isOrdered = true)
public class Purchase_order
{	
	
 @DataField(pos = 1)
private String name;

@DataField(pos = 2, precision = 2)
private BigDecimal price;

@DataField(pos = 3)
private int amount;

getters() & setters()
	    }


Camel class:

package CamelBindy.Test;

import java.math.BigDecimal;

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();

Purchase_order order = new Purchase_order();
order.setAmount(1);
order.setPrice(new BigDecimal("39.95"));
order.setName("Camel in Action");
		        
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",order);
		       
		         
		       Thread.sleep(1000);
		        context.stop();

		}

	}



Here i am trying to convert the Purchase_order model class into FIX message
dataformat. When trying for CSV dataformat its working fine. But for FIX
message type its showing the following error.


java.lang.ClassCastException: *CamelBindy.Test.Purchase_order cannot be cast
to java.util.ArrayList*	at
org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat.marshal(BindyKeyValuePairDataFormat.java:63)
~[camel-bindy-2.12.1.jar:2.12.1]
	at
org.apache.camel.processor.MarshalProcessor.process(MarshalProcessor.java:59)
~[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
~[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.interceptor.BacklogTracerInterceptor.process(BacklogTracerInterceptor.java:84)
~[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
~[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:391)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:273)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:335)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
[camel-core-2.11.1.jar:2.11.1]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
[camel-core-2.11.1.jar:2.11.1]
	at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:60)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:366)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:337)
[camel-core-2.11.1.jar:2.11.1]
	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233)
[camel-core-2.11.1.jar:2.11.1]
	at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:337)
[camel-core-2.11.1.jar:2.11.1]
	at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:175)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:111)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:124)
[camel-core-2.11.1.jar:2.11.1]
	at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:131)
[camel-core-2.11.1.jar:2.11.1]
	at CamelBindy.Test.BindyTest.main(BindyTest.java:63) [bin/:na]



Kindly help me to correct the error.



--
View this message in context: http://camel.465427.n5.nabble.com/Model-object-into-FIX-message-conversion-using-Bindy-tp5743015.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message