Re: Is camel right for my project with Asterisk?

2021-09-20 Thread Claus Ibsen
Hi

For TCP networking then you can use netty as a server and write a
custom codec to plugin to any kind of custom format.

In this codec, you can parse it accordingly to your format. It seems
like \n\n is the end of record indicator.
See Netty project for how to write custom codec.

And there is a simple custom codec example here
https://github.com/camelinaction/camelinaction2/tree/master/chapter6/netty/src/test/java/camelinaction

And for the asterix component, then we sure love contributions. But it
may be an effort to implement it as server part,
if there is not something more easy to reuse. Otherwise there is as
mention Netty.


On Tue, Sep 14, 2021 at 10:08 AM Mario Giammarco  wrote:
>
> Hi,
> I have used successfully Camel in the past.
> But again I want to use it in a message passing project to see if:
> - I can do with less lines of code comparing to using only Java
> - the readability of the code is improved (so I want to use all Camel 
> features and not write custom beans to do all the work)
>
> Basically the project is this: I want to do a Camel application that receives 
> Asterisk AMI messages from clients, modify them, and send them to several 
> Asterisk servers depending on enriched message content.
>
> Actually I have these problems:
>
> - Camel has an Asterisk component but it seems unused/unsupported/proof of 
> concept
>
> - The asterisk component is client only, so I need to create a socket server 
> and parse messages. Messages are like this:
> key: value \n
> key: value \n
> \n\n
>   I hoped I can parse a string message like this and convert to a Camel 
> message (java map) with camel marshallers but I cannot find the right one. Or 
> probably I need to do an aggregator until double newline but again it seems 
> too complex to me.
>
> - I need to keep a state (for example: message come from an authenticated 
> client) and again I do not see an easy example to follow.
>
> So I am asking your help and your suggestions!
>
> Thanks in advance for any help.
> Mario
>


-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


ApacheCon starts tomorrow!

2021-09-20 Thread Rich Bowen
ApacheCon @Home starts tomorrow! Details at 
https://www.apachecon.com/acah2021/index.html


(Note: You're receiving this because you are subscribed to one or more 
user lists for Apache Software Foundation projects.)


We've got three days of great content lined up for you, spanning 14 
project communities. And we're very excited about the keynotes, with 
presentations from David Nalley, Ashley Wolfe, Mark Cox, Alison Parker, 
and Michael Weinberg. And we'll be hearing from our Platinum sponsors in 
their keynotes as well! (Schedule is at 
https://www.apachecon.com/acah2021/tracks/)


You can still register today, at 
https://www.apachecon.com/acah2021/register.html


We especially want to thank our sponsors, who have made this event possible:

Strategic sponsor: Google
Platinum sponsors: Huawei, Tencent, Instaclustr, and Apple
Gold sponsors: AWS, Aiven, Gradle, Replicated, Red 
Hat, Baidu, Fiter, Cerner, Dremio, and Didi
Silver sponsors: Bamboo, SpereEx, Microsoft, Imply, Securonix, DataStax, 
and Crafter Software

Bronze sponsor: Technical Arts

Please join us on our Slack for discussion before, during, and after the 
event! http://s.apache.org/apachecon-slack


And follow us on Twitter - https://twitter.com/apachecon - for tips and 
announcements during the event.


See you tomorrow!


--
Rich Bowen, VP Conferences
The Apache Software Foundation
https://apachecon.com/
@apachecon


Re: No suitable setter for property, dataformat.csv

2021-09-20 Thread Mikael Andersson Wigander
Digged deeper and found that Camel is expecting a String[] initially but then 
it fails again.


I get a different stackTrace


2021-09-20 13:47:54,708 WARN  [org.apa.cam.com.sed.SedaConsumer] (Camel 
(camel-3) thread #27 - seda://textImporter) Error processing exchange. 
Exchange[FF9E23AAB732300-0001]. Caused by: 
[org.apache.camel.ResolveEndpointFailedException - Failed to resolve endpoint: 
dataformat://csv:marshal?header=%5BLjava.lang.String%3B%401f4adc4e due to: 
Error binding property (header=[Ljava.lang.String;@1f4adc4e) with name: header 
on bean: org.apache.camel.dataformat.csv.CsvDataFormat@5eed94ae with value: 
[Ljava.lang.String;@1f4adc4e]: org.apache.camel.ResolveEndpointFailedException: 
Failed to resolve endpoint: 
dataformat://csv:marshal?header=%5BLjava.lang.String%3B%401f4adc4e due to: 
Error binding property (header=[Ljava.lang.String;@1f4adc4e) with name: header 
on bean: org.apache.camel.dataformat.csv.CsvDataFormat@5eed94ae with value: 
[Ljava.lang.String;@1f4adc4e
at 
org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:962)
at 
org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:853)
at 
org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:73)
at 
org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:120)
at 
org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:99)
at 
org.apache.camel.processor.SendDynamicProcessor.resolveEndpoint(SendDynamicProcessor.java:296)
at 
org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:157)
at 
org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.doRun(RedeliveryErrorHandler.java:804)
at 
org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.run(RedeliveryErrorHandler.java:712)
at 
org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:179)
at 
org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:184)
at 
org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398)
at 
org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:269)
at 
org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:187)
at 
org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:130)
at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: org.apache.camel.PropertyBindingException: Error binding property 
(header=[Ljava.lang.String;@1f4adc4e) with name: header on bean: 
org.apache.camel.dataformat.csv.CsvDataFormat@5eed94ae with value: 
[Ljava.lang.String;@1f4adc4e
at 
org.apache.camel.support.PropertyBindingSupport.setSimplePropertyViaReflection(PropertyBindingSupport.java:720)
at 
org.apache.camel.support.PropertyBindingSupport.doSetPropertyValue(PropertyBindingSupport.java:463)
at 
org.apache.camel.support.PropertyBindingSupport.doBuildPropertyOgnlPath(PropertyBindingSupport.java:321)
at 
org.apache.camel.support.PropertyBindingSupport.doBindProperties(PropertyBindingSupport.java:210)
at 
org.apache.camel.support.PropertyBindingSupport.access$100(PropertyBindingSupport.java:88)
at 
org.apache.camel.support.PropertyBindingSupport$Builder.bind(PropertyBindingSupport.java:1812)
at 
org.apache.camel.support.PropertyBindingSupport.bindProperties(PropertyBindingSupport.java:116)
at 
org.apache.camel.component.dataformat.DataFormatComponent.createEndpoint(DataFormatComponent.java:55)
at 
org.apache.camel.support.DefaultComponent.createEndpoint(DefaultComponent.java:171)
at 
org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:928)
... 18 more
Caused by: java.lang.IllegalArgumentException: Could not find a suitable setter 
for property: header as there isn't a setter method with same type: 
java.lang.String nor type conversion possible: No type converter available to 
convert from type: java.lang.String to the required type: java.lang.String[] 
with value [Ljava.lang.String;@1f4adc4e
at 
org.apache.camel.support.IntrospectionSupport.setProperty(IntrospectionSupport.java:845)
at 
org.apache.camel.impl.engine.DefaultBeanIntrospection.setProperty(DefaultBeanIntrospection.java:199)
at 
org.apache.camel.support.PropertyBindingSupport.doSetSimplePropertyViaReflection(PropertyBindingSupport.java:829)
at 

Re: No suitable setter for property, dataformat.csv

2021-09-20 Thread Claus Ibsen
Hi

We can improve this so I created a ticket
https://issues.apache.org/jira/browse/CAMEL-16987

On Mon, Sep 20, 2021 at 12:49 PM Claus Ibsen  wrote:
>
> Hi
>
> Ah yeah converting to array is a bit shady as checking for the type of
> what they arrays holds is needed.
>
> But ideally it should use the ArrayTypeConverter as fallback in this
> case. Can you try a plain unit test / standalone with spring boot or
> quarkus.
>
> On Mon, Sep 20, 2021 at 11:11 AM Mikael Andersson Wigander
>  wrote:
> >
> > Hi
> >
> > Thanks but it doesn't work.
> >
> > Same issue:
> >
> > Caused by: java.lang.IllegalArgumentException: Could not find a suitable 
> > setter for property: header as there isn't a setter method with same type: 
> > java.lang.String nor type conversion possible: No type converter available 
> > to convert from type: java.lang.String to the required type: 
> > java.lang.String[] with value 
> > status,trade_date,sec_settle_date,fund_name,client_account,trade_reference,uti,broker_id,security_code,isin,fee,quantity,currency,market_price,loan_value,trade_time,trade_venue
> >
> >
> > /M
> >
> > ‐‐‐ Original Message ‐‐‐
> >
> > On Monday, September 20th, 2021 at 06:38, Claus Ibsen 
> >  wrote:
> >
> > > Hi
> > >
> > > > in.setHeader("ColumnNames", new ArrayList<>(headers));
> > >
> > > Store that header as a single string with comma separated values,
> > >
> > > On Sun, Sep 19, 2021 at 5:37 PM Mikael Andersson Wigander
> > >
> > > mikael.andersson.wigan...@pm.me.invalid wrote:
> > >
> > > > HI
> > > >
> > > > I'm converting a route from Camel 2.25.0 Spring Boot to latest Quarkus.
> > > >
> > > > The route parses a CSV file, splits it and use either headers if exist 
> > > > or creates headers if not, sends it to a bean for further processing 
> > > > ending up as amessage in a JMS.
> > > >
> > > > This was working fine but now when I run it in Quarkus I receive the 
> > > > following Exception:
> > > >
> > > > Caused by: java.lang.IllegalArgumentException: Could not find a 
> > > > suitable setter for property: header as there isn't a setter method 
> > > > with same type: java.lang.String nor type conversion possible: No type 
> > > > converter available to convert from type: java.lang.String to the 
> > > > required type: java.lang.String[] with value [status, trade_date, 
> > > > sec_settle_date, fund_name, client_account, trade_reference, uti, 
> > > > broker_id, security_code, isin, fee, quantity, currency, market_price, 
> > > > loan_value, trade_time, trade_venue]
> > > >
> > > > Route:
> > > >
> > > > from(seda("textImporter"))
> > > >
> > > > .description("DATA-IMPORTER-TEXT",
> > > >
> > > > "Imports data from text files such as .txt, .csv, .tab",
> > > >
> > > > "en")
> > > >
> > > > .toD("dataformat:csv:unmarshal?delimiter=${header.FileSplitter}=${header.UseHeader}")
> > > >
> > > > .split()
> > > >
> > > > .body()
> > > >
> > > > .streaming()
> > > >
> > > > .parallelProcessing(false)
> > > >
> > > > .process(exchange -> {
> > > >
> > > > final Message in = exchange.getIn();
> > > >
> > > > final Map body = new LinkedHashMap<>();
> > > >
> > > > if (!in.getHeader("UseHeader", Boolean.class)) {
> > > >
> > > > final List list = in.getBody(List.class);
> > > >
> > > > IntStream.range(0, list.size())
> > > >
> > > > .forEach(i -> body.put(i + "", list.get(i)));
> > > >
> > > > } else {
> > > >
> > > > body.putAll(in.getBody(Map.class));
> > > >
> > > > }
> > > >
> > > > final Set headers = body.keySet();
> > > >
> > > > in.setHeader("ColumnNames", new ArrayList<>(headers));
> > > >
> > > > final String idPath = in.getHeader("IdPath", String.class);
> > > >
> > > > in.setHeader("InternalReference", body.get(idPath));
> > > >
> > > > final List> newList = new ArrayList<>(Set.of(body));
> > > >
> > > > in.setBody(newList, List.class);
> > > >
> > > > })
> > > >
> > > > .toD("dataformat:csv:marshal?header=${header.ColumnNames}")
> > > >
> > > > .convertBodyTo(String.class)
> > > >
> > > > .log(LoggingLevel.DEBUG, "${body}")
> > > >
> > > > .bean(XSDMapping.class, "create")
> > > >
> > > > .marshal(jaxbDataFormat)
> > > >
> > > > .convertBodyTo(String.class)
> > > >
> > > > .to("{{jms.queue.outgoing}}")
> > > >
> > > > .to(log("FILE-IMPORTER-TEXT").level("DEBUG")
> > > >
> > > > .groupInterval(5000L)
> > > >
> > > > .groupActiveOnly(true))
> > > >
> > > > .choice()
> > > >
> > > > .when(simple("${header.CamelSplitComplete} == true"))
> > > >
> > > > .log("Number of records split: ${header.CamelSplitSize}")
> > > >
> > > > .log("Importing complete: ${header.CamelFileName}")
> > > >
> > > > .endChoice()
> > > >
> > > > .end();
> > > >
> > > > Using Quarkus 2.2.3.Final on Java 11, Camel 3.11.1
> > > >
> > > > /M
> > >
> > > --
> > >
> > > Claus Ibsen
> > > ---
> > >
> > > http://davsclaus.com @davsclaus
> > >
> > > Camel in Action 2: https://www.manning.com/ibsen2
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: 

Re: No suitable setter for property, dataformat.csv

2021-09-20 Thread Claus Ibsen
Hi

Ah yeah converting to array is a bit shady as checking for the type of
what they arrays holds is needed.

But ideally it should use the ArrayTypeConverter as fallback in this
case. Can you try a plain unit test / standalone with spring boot or
quarkus.

On Mon, Sep 20, 2021 at 11:11 AM Mikael Andersson Wigander
 wrote:
>
> Hi
>
> Thanks but it doesn't work.
>
> Same issue:
>
> Caused by: java.lang.IllegalArgumentException: Could not find a suitable 
> setter for property: header as there isn't a setter method with same type: 
> java.lang.String nor type conversion possible: No type converter available to 
> convert from type: java.lang.String to the required type: java.lang.String[] 
> with value 
> status,trade_date,sec_settle_date,fund_name,client_account,trade_reference,uti,broker_id,security_code,isin,fee,quantity,currency,market_price,loan_value,trade_time,trade_venue
>
>
> /M
>
> ‐‐‐ Original Message ‐‐‐
>
> On Monday, September 20th, 2021 at 06:38, Claus Ibsen  
> wrote:
>
> > Hi
> >
> > > in.setHeader("ColumnNames", new ArrayList<>(headers));
> >
> > Store that header as a single string with comma separated values,
> >
> > On Sun, Sep 19, 2021 at 5:37 PM Mikael Andersson Wigander
> >
> > mikael.andersson.wigan...@pm.me.invalid wrote:
> >
> > > HI
> > >
> > > I'm converting a route from Camel 2.25.0 Spring Boot to latest Quarkus.
> > >
> > > The route parses a CSV file, splits it and use either headers if exist or 
> > > creates headers if not, sends it to a bean for further processing ending 
> > > up as amessage in a JMS.
> > >
> > > This was working fine but now when I run it in Quarkus I receive the 
> > > following Exception:
> > >
> > > Caused by: java.lang.IllegalArgumentException: Could not find a suitable 
> > > setter for property: header as there isn't a setter method with same 
> > > type: java.lang.String nor type conversion possible: No type converter 
> > > available to convert from type: java.lang.String to the required type: 
> > > java.lang.String[] with value [status, trade_date, sec_settle_date, 
> > > fund_name, client_account, trade_reference, uti, broker_id, 
> > > security_code, isin, fee, quantity, currency, market_price, loan_value, 
> > > trade_time, trade_venue]
> > >
> > > Route:
> > >
> > > from(seda("textImporter"))
> > >
> > > .description("DATA-IMPORTER-TEXT",
> > >
> > > "Imports data from text files such as .txt, .csv, .tab",
> > >
> > > "en")
> > >
> > > .toD("dataformat:csv:unmarshal?delimiter=${header.FileSplitter}=${header.UseHeader}")
> > >
> > > .split()
> > >
> > > .body()
> > >
> > > .streaming()
> > >
> > > .parallelProcessing(false)
> > >
> > > .process(exchange -> {
> > >
> > > final Message in = exchange.getIn();
> > >
> > > final Map body = new LinkedHashMap<>();
> > >
> > > if (!in.getHeader("UseHeader", Boolean.class)) {
> > >
> > > final List list = in.getBody(List.class);
> > >
> > > IntStream.range(0, list.size())
> > >
> > > .forEach(i -> body.put(i + "", list.get(i)));
> > >
> > > } else {
> > >
> > > body.putAll(in.getBody(Map.class));
> > >
> > > }
> > >
> > > final Set headers = body.keySet();
> > >
> > > in.setHeader("ColumnNames", new ArrayList<>(headers));
> > >
> > > final String idPath = in.getHeader("IdPath", String.class);
> > >
> > > in.setHeader("InternalReference", body.get(idPath));
> > >
> > > final List> newList = new ArrayList<>(Set.of(body));
> > >
> > > in.setBody(newList, List.class);
> > >
> > > })
> > >
> > > .toD("dataformat:csv:marshal?header=${header.ColumnNames}")
> > >
> > > .convertBodyTo(String.class)
> > >
> > > .log(LoggingLevel.DEBUG, "${body}")
> > >
> > > .bean(XSDMapping.class, "create")
> > >
> > > .marshal(jaxbDataFormat)
> > >
> > > .convertBodyTo(String.class)
> > >
> > > .to("{{jms.queue.outgoing}}")
> > >
> > > .to(log("FILE-IMPORTER-TEXT").level("DEBUG")
> > >
> > > .groupInterval(5000L)
> > >
> > > .groupActiveOnly(true))
> > >
> > > .choice()
> > >
> > > .when(simple("${header.CamelSplitComplete} == true"))
> > >
> > > .log("Number of records split: ${header.CamelSplitSize}")
> > >
> > > .log("Importing complete: ${header.CamelFileName}")
> > >
> > > .endChoice()
> > >
> > > .end();
> > >
> > > Using Quarkus 2.2.3.Final on Java 11, Camel 3.11.1
> > >
> > > /M
> >
> > --
> >
> > Claus Ibsen
> > ---
> >
> > http://davsclaus.com @davsclaus
> >
> > Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: No suitable setter for property, dataformat.csv

2021-09-20 Thread Mikael Andersson Wigander
Hi

Thanks but it doesn't work.

Same issue:

Caused by: java.lang.IllegalArgumentException: Could not find a suitable setter 
for property: header as there isn't a setter method with same type: 
java.lang.String nor type conversion possible: No type converter available to 
convert from type: java.lang.String to the required type: java.lang.String[] 
with value 
status,trade_date,sec_settle_date,fund_name,client_account,trade_reference,uti,broker_id,security_code,isin,fee,quantity,currency,market_price,loan_value,trade_time,trade_venue


/M

‐‐‐ Original Message ‐‐‐

On Monday, September 20th, 2021 at 06:38, Claus Ibsen  
wrote:

> Hi
>
> > in.setHeader("ColumnNames", new ArrayList<>(headers));
>
> Store that header as a single string with comma separated values,
>
> On Sun, Sep 19, 2021 at 5:37 PM Mikael Andersson Wigander
>
> mikael.andersson.wigan...@pm.me.invalid wrote:
>
> > HI
> >
> > I'm converting a route from Camel 2.25.0 Spring Boot to latest Quarkus.
> >
> > The route parses a CSV file, splits it and use either headers if exist or 
> > creates headers if not, sends it to a bean for further processing ending up 
> > as amessage in a JMS.
> >
> > This was working fine but now when I run it in Quarkus I receive the 
> > following Exception:
> >
> > Caused by: java.lang.IllegalArgumentException: Could not find a suitable 
> > setter for property: header as there isn't a setter method with same type: 
> > java.lang.String nor type conversion possible: No type converter available 
> > to convert from type: java.lang.String to the required type: 
> > java.lang.String[] with value [status, trade_date, sec_settle_date, 
> > fund_name, client_account, trade_reference, uti, broker_id, security_code, 
> > isin, fee, quantity, currency, market_price, loan_value, trade_time, 
> > trade_venue]
> >
> > Route:
> >
> > from(seda("textImporter"))
> >
> > .description("DATA-IMPORTER-TEXT",
> >
> > "Imports data from text files such as .txt, .csv, .tab",
> >
> > "en")
> >
> > .toD("dataformat:csv:unmarshal?delimiter=${header.FileSplitter}=${header.UseHeader}")
> >
> > .split()
> >
> > .body()
> >
> > .streaming()
> >
> > .parallelProcessing(false)
> >
> > .process(exchange -> {
> >
> > final Message in = exchange.getIn();
> >
> > final Map body = new LinkedHashMap<>();
> >
> > if (!in.getHeader("UseHeader", Boolean.class)) {
> >
> > final List list = in.getBody(List.class);
> >
> > IntStream.range(0, list.size())
> >
> > .forEach(i -> body.put(i + "", list.get(i)));
> >
> > } else {
> >
> > body.putAll(in.getBody(Map.class));
> >
> > }
> >
> > final Set headers = body.keySet();
> >
> > in.setHeader("ColumnNames", new ArrayList<>(headers));
> >
> > final String idPath = in.getHeader("IdPath", String.class);
> >
> > in.setHeader("InternalReference", body.get(idPath));
> >
> > final List> newList = new ArrayList<>(Set.of(body));
> >
> > in.setBody(newList, List.class);
> >
> > })
> >
> > .toD("dataformat:csv:marshal?header=${header.ColumnNames}")
> >
> > .convertBodyTo(String.class)
> >
> > .log(LoggingLevel.DEBUG, "${body}")
> >
> > .bean(XSDMapping.class, "create")
> >
> > .marshal(jaxbDataFormat)
> >
> > .convertBodyTo(String.class)
> >
> > .to("{{jms.queue.outgoing}}")
> >
> > .to(log("FILE-IMPORTER-TEXT").level("DEBUG")
> >
> > .groupInterval(5000L)
> >
> > .groupActiveOnly(true))
> >
> > .choice()
> >
> > .when(simple("${header.CamelSplitComplete} == true"))
> >
> > .log("Number of records split: ${header.CamelSplitSize}")
> >
> > .log("Importing complete: ${header.CamelFileName}")
> >
> > .endChoice()
> >
> > .end();
> >
> > Using Quarkus 2.2.3.Final on Java 11, Camel 3.11.1
> >
> > /M
>
> --
>
> Claus Ibsen
> ---
>
> http://davsclaus.com @davsclaus
>
> Camel in Action 2: https://www.manning.com/ibsen2