I have some examples on my blog:

http://funnifi.blogspot.com

Regards,
Matt


> On Jul 7, 2016, at 5:03 PM, Anuj Handa <anujha...@gmail.com> wrote:
> 
> is there some examples of the InvokeSscriptedProcessor.
> i am quite new to nifi any examples i can replicate would help greatly.. 
> 
>> On Thu, Jul 7, 2016 at 11:45 AM, Matt Burgess <mattyb...@gmail.com> wrote:
>> It will be fixed in 0.7.0 [1].  Also you could use
>> InvokeScriptedProcessor to replace both the ExecuteScript and
>> RouteOnAttribute, since the scripted processor can define the
>> relationships and provide the logic to extract the arbitrary JSON
>> keys.
>> 
>> Regards,
>> Matt
>> 
>> [1] https://issues.apache.org/jira/browse/NIFI-1822
>> 
>> On Thu, Jul 7, 2016 at 11:21 AM, Bryan Bende <bbe...@gmail.com> wrote:
>> > I think you actually need to use both ExecuteScript and RouteOnAttribute
>> > together.
>> >
>> > The reason is that ExecuteScript only has success and failure 
>> > relationships,
>> > so all you can do there is extract the value you are interested in (order 
>> > or
>> > refund) and put it in an attribute and route to success,
>> > then send it to RouteOnAttribute which can have the dynamic relationships.
>> >
>> > There was a limitation where ExecuteScript could not run concurrent tasks,
>> > and I know it was fixed, but not sure if it was fixed in 0.6.1 or for the
>> > next upcoming release (0.7.0) which is happening soon.
>> > Maybe someone else can chime about when this was fixed.
>> >
>> > On Thu, Jul 7, 2016 at 11:13 AM, Anuj Handa <anujha...@gmail.com> wrote:
>> >>
>> >> Hi Bryan,
>> >>
>> >> Thats correct i want to route on element name so "ORDER" through one and
>> >> "REFUND" to another. The reason is based on element  name the structure of
>> >> the JSON could be different so the subsequent processing depends on the
>> >> element name.
>> >>
>> >> Processing thousands of messages per minute which would be better using
>> >> RouteonAttribute or ExecuteScript ? Since the entire JSON doc could come 
>> >> in
>> >> the attribute if i use  $.POSTransaction. i would think it would slow it
>> >> down compared with if the attribute value only has "ORDER"
>> >>
>> >> Anuj
>> >>
>> >>
>> >>
>> >> On Thu, Jul 7, 2016 at 10:59 AM, Bryan Bende <bbe...@gmail.com> wrote:
>> >>>
>> >>> Anuj,
>> >>>
>> >>> Just to clarify, you want to route on the name of the element under
>> >>> POSTransaction? Meaning, route "Order" to one place and "Refund" to 
>> >>> another?
>> >>>
>> >>> I'm not a JSON Path expert, but I can't come up with a way to get  just
>> >>> an element name from JSON path, it is usually used to get the value of a
>> >>> known path.
>> >>>
>> >>> If you used $.POSTransaction. as the expression I think you would get
>> >>> back everything under POSTransaction  including the "Order" or "Refund"
>> >>> part, and
>> >>> then in RouteOnAttribute you could use expression language to see what it
>> >>> starts ${yourAttribute:startsWith('Order')} or maybe use contains() 
>> >>> instead
>> >>> of startsWith.
>> >>>
>> >>> Another completely different option is to use the ExecuteScript processor
>> >>> to write a Groovy/Jython/etc script that gets the name of the first 
>> >>> element
>> >>> under POSTransaction and adds it as an attribute.
>> >>>
>> >>> -Bryan
>> >>>
>> >>>
>> >>> On Thu, Jul 7, 2016 at 8:34 AM, Anuj Handa <anujha...@gmail.com> wrote:
>> >>>>
>> >>>> Hi Folks,
>> >>>>
>> >>>> I have following two JSON documents and i would like to route them based
>> >>>> on what the value is. In the below examples its order and refund. i want
>> >>>> this to be dynamic as i can expect range of values.
>> >>>>
>> >>>> i was thinking of using EvaluateJsonPath and reading the Value of this
>> >>>> field in the attribute. i was unable to get what Path expression should 
>> >>>> be .
>> >>>>
>> >>>> $.POSTransaction.* returns me the entire JSON and not just the Order
>> >>>> value
>> >>>>
>> >>>> is it possible to make it dynamic ?  or is there a better/different  way
>> >>>> to do this
>> >>>>
>> >>>> {
>> >>>> "POSTransaction": {
>> >>>> "Order": {
>> >>>>
>> >>>> {
>> >>>> "POSTransaction": {
>> >>>> "Refund": {
>> >>>>
>> >>>>
>> >>>> Regards,
>> >>>> Anuj
>> >>>
>> >>>
>> >>
>> >
> 

Reply via email to