Announcement Announcement Module
Collapse
No announcement yet.
JMS Property to Sprint Integration Header Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMS Property to Sprint Integration Header

    I have a Spring Integration pipeline that includes a jms backed channel. In a test environment we're trying to test part of the processing starting from the JMS backed channel, rather than test the whole pipeline that would require other externals systems, but we have hit an issue with a missing Spring Integration Header that is required for processing.

    The full processing pipeline is as follows:-

    1) The processing starts with a 'custom inbound channel adapter' that is invoked when a message is received from an external system via Webmethods (another ESB), when the adapter is triggered it creates a Spring Integration Message with a payload of xml string and Header with a name of "submissionReference".

    2) The message goes to channel that is jms backed :-

    Code:
    <int-jms:channel id="submission-jms" queue="myQueueDestination"  />

    3) A transformer converts the String payload to XML Bean.

    4) A Service activator is called :-

    Code:
    @ServiceActivator
    @Override
    @Transactional
    public void processSubmission( 
    	@Header(value = "submissionReference", required = true) String submissionRef, 
    		PayloadDocument payloadXmlBean) {
             .....
    
    }
    Now all works fine if the whole pipeline is tested.

    However for testing purposes we want to be able to drop JMS messages into the jms backed channel "submission-jms" , however the Service Activator requires a Spring Integration Header "submissionReference" to be set. So we think we need to set this as a JMS header property "submissionReference", but Spring Integration still believes this is not set once it reaches the Service Activator.

    We though that JMS Properties were mapped to Spring Integration Header properties ?

    To try to understand what is going on, I paused the JMS Queue (in weblogic console) then inspected the JMS Message and it's properties as it resides in the JMS queue :-

    - when testing starting at the JMS point, I can see the string xml contents of the JMS message and see that a JMS property "submissionReference" has a value.

    In the log4J output I see the header is not set :-
    Code:
    [Headers={timestamp=1349701266224, id=a64ddb11-a1ee-4420-8d7b-51234b5d8101}]
    - when testing the complete pipeline that works, I see a message of type org.springframework.integration.message.GenericMes sage but the WL console won't allow me to inspect - as I presume it is an Object/binary JMS message type

    In the log4J output (when things work) I see the header is set :-
    Code:
    [Headers={timestamp=1349705214167, id=b3e1f180-e9c3-43fa-a6e4-97d321c6a5db, submissionReference=444}]




    Code:
    Caused by: java.lang.IllegalArgumentException: required header not available:  submissionReference
            at org.springframework.util.Assert.isTrue(Assert.java:65)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69)
            at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:84)
            at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
            at org.springframework.expression.spel.ast.Ternary.getValueInternal(Ternary.java:55)
            at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:65)
            at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
            at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
            at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
            at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
            at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:225)
            at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:125)
            at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73)

    All we need is a way to drop a message into the "submission-jms" to allow testing by our Test Team without the Custom Inbound channel Adapter.

    How can we drop a JMS message into "submission-jms" channel and have Spring Integration happy that there is a header property named "submissionReference" ?

  • #2
    Did you find fix for your problem.?

    Did you find fix for your problem? I am having same issue.





    Originally posted by PeteTh View Post
    I have a Spring Integration pipeline that includes a jms backed channel. In a test environment we're trying to test part of the processing starting from the JMS backed channel, rather than test the whole pipeline that would require other externals systems, but we have hit an issue with a missing Spring Integration Header that is required for processing.

    The full processing pipeline is as follows:-

    1) The processing starts with a 'custom inbound channel adapter' that is invoked when a message is received from an external system via Webmethods (another ESB), when the adapter is triggered it creates a Spring Integration Message with a payload of xml string and Header with a name of "submissionReference".

    2) The message goes to channel that is jms backed :-

    Code:
    <int-jms:channel id="submission-jms" queue="myQueueDestination"  />

    3) A transformer converts the String payload to XML Bean.

    4) A Service activator is called :-

    Code:
    @ServiceActivator
    @Override
    @Transactional
    public void processSubmission( 
    	@Header(value = "submissionReference", required = true) String submissionRef, 
    		PayloadDocument payloadXmlBean) {
             .....
    
    }
    Now all works fine if the whole pipeline is tested.

    However for testing purposes we want to be able to drop JMS messages into the jms backed channel "submission-jms" , however the Service Activator requires a Spring Integration Header "submissionReference" to be set. So we think we need to set this as a JMS header property "submissionReference", but Spring Integration still believes this is not set once it reaches the Service Activator.

    We though that JMS Properties were mapped to Spring Integration Header properties ?

    To try to understand what is going on, I paused the JMS Queue (in weblogic console) then inspected the JMS Message and it's properties as it resides in the JMS queue :-

    - when testing starting at the JMS point, I can see the string xml contents of the JMS message and see that a JMS property "submissionReference" has a value.

    In the log4J output I see the header is not set :-
    Code:
    [Headers={timestamp=1349701266224, id=a64ddb11-a1ee-4420-8d7b-51234b5d8101}]
    - when testing the complete pipeline that works, I see a message of type org.springframework.integration.message.GenericMes sage but the WL console won't allow me to inspect - as I presume it is an Object/binary JMS message type

    In the log4J output (when things work) I see the header is set :-
    Code:
    [Headers={timestamp=1349705214167, id=b3e1f180-e9c3-43fa-a6e4-97d321c6a5db, submissionReference=444}]




    Code:
    Caused by: java.lang.IllegalArgumentException: required header not available:  submissionReference
            at org.springframework.util.Assert.isTrue(Assert.java:65)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69)
            at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:84)
            at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
            at org.springframework.expression.spel.ast.Ternary.getValueInternal(Ternary.java:55)
            at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:65)
            at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
            at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
            at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
            at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
            at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:225)
            at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:125)
            at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73)

    All we need is a way to drop a message into the "submission-jms" to allow testing by our Test Team without the Custom Inbound channel Adapter.

    How can we drop a JMS message into "submission-jms" channel and have Spring Integration happy that there is a header property named "submissionReference" ?

    Comment


    • #3
      I didn't see the original posting in October, but you can't use a channel that way.

      The queue that backs the channel contains a serialized version of messages sent to the channel.

      It is not mapped in the same way as, for example, an inbound channel adapter.

      The channel was never intended as a mechanism to inject data mid-flow.

      Comment

      Working...
      X