Announcement Announcement Module
Collapse
No announcement yet.
Unpredictable behavior when using @Header and boolean (primitive) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unpredictable behavior when using @Header and boolean (primitive)

    Hi,

    I tried to use the @Header annotation together with a boolean (primitive) in my service activator.

    Code:
    @Override
    @ServiceActivator
    public final void processBusinessObject(final T businessObject, @Header("invalidation") final boolean invalidation) {
       ...
    }
    But in my multi-threaded import I get about 0-3 failures on every run (about 3000 messages). I have four cores in my machine.

    Code:
    Caused by: java.lang.IllegalArgumentException: Wrong number of arguments. Expected types {class xxx.messages.AbstractWarehouseAwareBusinessObject, boolean}, but received values {[Payload=xxx.messages.VariantAvailabilityBusinessObject@118bbe2][Headers={UniqueTransactionID=b98f27b9-b9bc-4e7c-bf94-5fd7c9837af2, TransactionDST=unknown, springintegration_id=ea956b09-fc42-4252-9e40-b4c4d27f8583, TransactionType=BatchFile, springintegration_jms_redelivered=false, springintegration_jms_messageId=ID:3f27f598:35249c0020:12B7B639EDA, invalidation=false, springintegration_timestamp=1286265347849, TransactionDateTime=Tue Oct 05 09:55:47 CEST 2010, springintegration_jms_correlationId=Message 1, springintegration_file_originalFile=C:\Import\working\2010-10-05-09.55.47.b98f27b9-b9bc-4e7c-bf94-5fd7c9837af2.msg, SourceSystemName=batchedfile}]}.
            at org.springframework.integration.util.DefaultMethodInvoker.invokeMethod(DefaultMethodInvoker.java:71)
            at org.springframework.integration.handler.MessageMappingMethodInvoker.doInvokeMethod(MessageMappingMethodInvoker.java:160)
            at org.springframework.integration.handler.MessageMappingMethodInvoker.invokeMethod(MessageMappingMethodInvoker.java:107)
            at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:49)
            at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:91)
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:59)
            ... 37 more
    But when I changed my code to use the wrapper Boolean everything runs without any problem.

    Code:
    @Override
    @ServiceActivator
    public final void processBusinessObject(final T businessObject, @Header("invalidation") final Boolean invalidation) {
       ...
    }
    Any ideas?
    Last edited by jakeri; Oct 8th, 2010, 12:41 AM. Reason: typo in debug message

  • #2
    I noticed that the header name in the error trace you included there was "cdnInvalidation" and not "invalidation". Is there any chance that you are encountering just a handful of those while the others are always "invalidation"?

    If so, that might explain the issue. If you had 3 out of 3000 that were actually missing the "invalidation" header altogether, then it would be a NULL return which would map to a Boolean object as null but would have a problem when attempting to convert to a primitive boolean.

    Comment


    • #3
      That is just a typo in my example here. All code uses cdnInvalidation but I changed in example for this post.

      (tried to anonymize to invalidation but failed)

      Comment

      Working...
      X