Announcement Announcement Module
Collapse
No announcement yet.
Referencing an enum in payload expression Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Referencing an enum in payload expression

    I am trying to create a filter that references an Enum that is defined in the com.services.Event class.
    THe enum is EventType and has Started and Finished defined.
    This is the filter:
    <si:filter input-channel="myChannel" output-channel="outputCh" expression="payload.eventType.equals(#{T(com.servi ces.Event$EventType).Started})" discard-channel="nullChannel"/>

    This is the enum
    public static enum EventType
    {
    Started, Finished
    }

    This fails with the message below. If I reference some other field in the payload message, it works fine.
    I only run into this with an enum. Any ideas?



    Caused by: org.springframework.expression.spel.SpelEvaluation Exception: EL1008Epos 18): Field or property 'Started' cannot be found on object of type 'org.springframework.integration.message.GenericMe ssage'
    at org.springframework.expression.spel.ast.PropertyOr FieldReference.readProperty(PropertyOrFieldReferen ce.java:208)
    at org.springframework.expression.spel.ast.PropertyOr FieldReference.getValueInternal(PropertyOrFieldRef erence.java:72)
    at org.springframework.expression.spel.ast.MethodRefe rence.getValueInternal(MethodReference.java:65)
    at org.springframework.expression.spel.ast.CompoundEx pression.getValueInternal(CompoundExpression.java: 57)
    at org.springframework.expression.spel.ast.SpelNodeIm pl.getTypedValue(SpelNodeImpl.java:102)
    at org.springframework.expression.spel.standard.SpelE xpression.getValue(SpelExpression.java:102)
    at org.springframework.integration.util.AbstractExpre ssionEvaluator.evaluateExpression(AbstractExpressi onEvaluator.java:114)
    at org.springframework.integration.util.AbstractExpre ssionEvaluator.evaluateExpression(AbstractExpressi onEvaluator.java:80)
    ... 46 more

  • #2
    Hello

    Have you tried it like this:
    Code:
    expression="payload.eventType.equals(T(com.servi ces.Event$EventType).Started)"
    ?

    Take care,
    Artem Bilan

    Comment


    • #3
      Thanks! That does the trick.

      Comment

      Working...
      X