You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by santoshkeleti <ke...@gmail.com> on 2017/01/19 10:49:27 UTC
How to read header of type java Map in choice block
hi All,
I have a situation where i have a header of type Map. based on the value of
key=3 i need to route the massage to different URIs.
i.e.
from("file:/home/santoshkeleti/Desktop/Camel/input?noop=true")
.to("http://"+conncterURL+"iso/parse?isoMsg="+iso).process(new Processor()
{
@Override
public void process(Exchange exchange) throws Exception {
map=exchange.getIn().getBody(String.class);
exchange.getIn().setHeader("map", map);
exchange.getIn().setHeader("isoMap", new
GsonBuilder().create().fromJson(map, Map.class));
}
}).choice()
.when(((Map)header("isoMap")).gety(3).equals("21300")
.toD("http://localhost:8080/CBS/iso/fundTransferISO?isoMsgMap=${header.map}");
But i am getting Error like can not cast valueBuilder to map.
Please provide me a solution. please
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-read-header-of-type-java-Map-in-choice-block-tp5792774.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to read header of type java Map in choice block
Posted by santoshkeleti <ke...@gmail.com>.
Thanks bro it is working and sorry bro, excuse me for so many emails,
i will study the simple language. and your awesome for the responses you
have given. you saved me. thanks
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-read-header-of-type-java-Map-in-choice-block-tp5792774p5792810.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to read header of type java Map in choice block
Posted by Claus Ibsen <cl...@gmail.com>.
when(simple("${header.isoMap[3]} == '213000'"))
Use [key] to lookup the map entry when using simple
And study yourself the simple language some more before writing many emails.
And there is a bunch of unit tests which you can use as inspiration
https://github.com/apache/camel/blob/master/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
On Thu, Jan 19, 2017 at 1:05 PM, santoshkeleti
<ke...@gmail.com> wrote:
> please excuse me bro,
>
> my map is {0=0200, 2=8000256072377943, 3=213000, 102=002028003453,
> 4=000000900000, 7=201117140654, 60=2013201320132013, 50=000, 41=80002523}
>
> i wrote the expression as follows,
>
> when(simple("${header[isoMap].get(\"3\")} == '213000'"))
>
> but it is not working.
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-read-header-of-type-java-Map-in-choice-block-tp5792774p5792801.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: How to read header of type java Map in choice block
Posted by santoshkeleti <ke...@gmail.com>.
please excuse me bro,
my map is {0=0200, 2=8000256072377943, 3=213000, 102=002028003453,
4=000000900000, 7=201117140654, 60=2013201320132013, 50=000, 41=80002523}
i wrote the expression as follows,
when(simple("${header[isoMap].get(\"3\")} == '213000'"))
but it is not working.
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-read-header-of-type-java-Map-in-choice-block-tp5792774p5792801.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to read header of type java Map in choice block
Posted by Claus Ibsen <cl...@gmail.com>.
Something a like:
when(simple("${header[isoMap].getY()} == '213000'"))
On Thu, Jan 19, 2017 at 12:39 PM, santoshkeleti
<ke...@gmail.com> wrote:
> Thanks bro,
>
> just i have tried simple but did not worked for me, may be i did some thing
> wrong.
> i am new to camel.
>
> from("file:/home/santoshkeleti/Desktop/Camel/input?noop=true")
> .to("http://"+conncterURL+"iso/parse?isoMsg="+iso).process(new
> Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> map=exchange.getIn().getBody(String.class);
> exchange.getIn().setHeader("map", map);
> exchange.getIn().setHeader("isoMap", new
> GsonBuilder().create().fromJson(map, Map.class));
> }
> }).choice()
>
> .when(PredicateBuilder.constant(simple("${in.header.isoMap[\"3\"]").equals("213000")))
>
> .toD("http://localhost:8080/CBS-Connector-0.0.1-SNAPSHOT/service/iso/fundTransferISO?isoMsgMap=${header.map}&"+"suspenseAccount="+suspenseAccount)
>
>
> help me. i have a assignment to complete. i am just following camel in
> Action book. but i dont have time read complete book that y i am asking
> help.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-read-header-of-type-java-Map-in-choice-block-tp5792774p5792799.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: How to read header of type java Map in choice block
Posted by santoshkeleti <ke...@gmail.com>.
Thanks bro,
just i have tried simple but did not worked for me, may be i did some thing
wrong.
i am new to camel.
from("file:/home/santoshkeleti/Desktop/Camel/input?noop=true")
.to("http://"+conncterURL+"iso/parse?isoMsg="+iso).process(new
Processor() {
@Override
public void process(Exchange exchange) throws Exception {
map=exchange.getIn().getBody(String.class);
exchange.getIn().setHeader("map", map);
exchange.getIn().setHeader("isoMap", new
GsonBuilder().create().fromJson(map, Map.class));
}
}).choice()
.when(PredicateBuilder.constant(simple("${in.header.isoMap[\"3\"]").equals("213000")))
.toD("http://localhost:8080/CBS-Connector-0.0.1-SNAPSHOT/service/iso/fundTransferISO?isoMsgMap=${header.map}&"+"suspenseAccount="+suspenseAccount)
help me. i have a assignment to complete. i am just following camel in
Action book. but i dont have time read complete book that y i am asking
help.
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-read-header-of-type-java-Map-in-choice-block-tp5792774p5792799.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to read header of type java Map in choice block
Posted by Claus Ibsen <cl...@gmail.com>.
Look at simple
http://camel.apache.org/simple
On Thu, Jan 19, 2017 at 11:49 AM, santoshkeleti
<ke...@gmail.com> wrote:
> hi All,
>
> I have a situation where i have a header of type Map. based on the value of
> key=3 i need to route the massage to different URIs.
> i.e.
> from("file:/home/santoshkeleti/Desktop/Camel/input?noop=true")
> .to("http://"+conncterURL+"iso/parse?isoMsg="+iso).process(new Processor()
> {
> @Override
> public void process(Exchange exchange) throws Exception {
> map=exchange.getIn().getBody(String.class);
> exchange.getIn().setHeader("map", map);
> exchange.getIn().setHeader("isoMap", new
> GsonBuilder().create().fromJson(map, Map.class));
> }
> }).choice()
> .when(((Map)header("isoMap")).gety(3).equals("21300")
>
> .toD("http://localhost:8080/CBS/iso/fundTransferISO?isoMsgMap=${header.map}");
>
>
> But i am getting Error like can not cast valueBuilder to map.
>
> Please provide me a solution. please
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-read-header-of-type-java-Map-in-choice-block-tp5792774.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2