Dmitry,
   You will want to use the RouteOnAttribute processor with a "routing
strategy" of "route to property name" and two added custom properties.

   That one added property would be used to identify the FlowFiles that a
mime type of text/xml.
   For example:
   property:                              value:
   type-xml                               ${'mime.type':equals('text/xml')}
   type-html                              ${'mime.type':equals('text/html')}

  The routeOnAttribute will then have three attributes (type-xml,
type-html,  and unmatched).
  How are you identifying the mime.type and setting that attribute on your
FlowFiles prior to this RouteOnAttribute?

Matt


On Thu, Mar 24, 2016 at 5:33 PM, Dmitry Goldenberg <[email protected]
> wrote:

> Thanks, Pierre.
>
> It doesn't look like NiFi would create 2 relationships, one per condition.
> It only seems to allow for 'matched' and 'unmatched' relationships.
> Therefore, I believe I'll need:
>
>    - a RouteOnAttribute with 'matched' that points to subflow for
>    processing of    property=is_xml, value=mimetype equals 'text/xml'
>    - the 'unmatched' on it would lead to the next RouteOnAttribute where
>    'matched' would point to subflow for processing of    property=is_html,
>    value=mimetype equals 'text/html'
>    - the 'unmatched' on the second RouteOnAttribute would lead to the
>    subflow for processing all other cases
>
> (It'll probably be OK to use the same boolean prop for 'is_xml' and
> 'is_html', something like 'is_match')
>
> It'd be quite great to have a visual representation of this if/then/else
> type of construct but the chained set of RouteOnAttribute's should work.
>
> - Dmitry
>
>
>
> On Thu, Mar 24, 2016 at 5:15 PM, Pierre Villard <
> [email protected]> wrote:
>
>> Hi Dmitry,
>>
>> I'd suggest to add RouteOnAttribute processor and add a custom property
>> by expected condition :
>> one property with name textxml (for example) and with value the EL you
>> suggested (it supposed that you have the mime type in one of the attribute
>> of your flow file)
>> property with name texthml (for example) and with value the EL
>> ${mimetype:equals('text/html')}
>>
>> then you will have two automaticcaly created relationship and one
>> "unmatched". It will answer your need.
>>
>> Hope this helps,
>> Pierre
>>
>> 2016-03-24 21:29 GMT+01:00 Dmitry Goldenberg <[email protected]>:
>>
>>> Hi,
>>>
>>> I'm looking for a 'best practice' to set up a conditional within a
>>> dataflow, based on some attribute(s).
>>>
>>> I want to express something like this:
>>>
>>> if ("mimetype" equals "text/xml") {
>>>     route FlowFile to XmlProcessingSubflow
>>> } else if ("mimetype" equals "text/html") {
>>>     route FlowFile to HtmlProcessingSubflow
>>> } else {
>>>     route FlowFile to DefaultDocProcessingSubflow
>>> }
>>>
>>> How can I do this in NiFi?  I'm looking at RouteOnAttribute but I can't
>>> quite grok the Routing Strategy:
>>>
>>> Route to Property name
>>> A copy of the FlowFile will be routed to each relationship whose
>>> corresponding expression evaluates to “true”.
>>>
>>> Route to ‘matched’ if all match
>>> Requires that all user-defined expressions evaluate to true for the
>>> FlowFile to be considered a match
>>>
>>> Route to ‘matched’ if any matches
>>> Requires that at least one user-defined expression evaluate to true for
>>> the FlowFile to be considered a match.
>>>
>>> The first option I'm quite confused about. Route to property? Where are
>>> the relationships I'd be routing to?
>>>
>>> The second option seems to be what I need. Presumably I can add a "New
>>> property" with the name "mimetype"; the value -- not sure. Perhaps this
>>> is ${mimetype:equals('text/xml')}    ?  But I already have "mimetype" in
>>> the property name.  Should the expression be somewhat different?
>>>
>>> Subsequently, if this allows me to route to one subflow based on one
>>> value, how do I route based on a different value of the mimetype, e.g.
>>> "text/html", to another subflow?
>>>
>>> Thanks.
>>> - Dmitry
>>>
>>>
>>>
>>>
>>
>

Reply via email to