Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Help on xml:xpath-router

  1. #11
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,015

    Default

    There's also

    Code:
    filename-generator-expression="headers['jms_messageId'].replace('<','').replace('>','') + '.bad'"
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  2. #12

    Default

    Hi Gary,

    thanks for the provided example !

    I'm checking the syntax because I got an error:

    Code:
    Offending resource: class path resource [applicationContext.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 62 in XML document from file [C:\projects\maven\workspace\myListener\target\test-classes\myListener-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The value of attribute "filename-generator-expression" associated with an element type "null" must not contain the '<' character.
    Thanks and regards
    nuvola

  3. #13
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,015

    Default

    Try '&lt;' and '&gt;' for '<' and '>'
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  4. #14

    Default

    ciao Gary,

    Your hint is perfect!

    ... I'm also trying to add a timestamp in the filename ...

    Code:
        <file:outbound-channel-adapter id="unknownMessageTypeChannel" directory="file:${unknownMessageType.directory}"
           filename-generator-expression="'${myQueue.jndiName}' + '_' + headers['jms_messageId'].replace('&lt;','').replace('&gt;','').replace(':','_') + '_' + new SimpleDateFormat('ddMMyyyy_HHmmss').format(new Date()) + '.xml'"/>
    The error is:

    Code:
    Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1003E:(pos 104): A problem occurred whilst attempting to construct an object of type 'SimpleDateFormat' using arguments '(java.lang.String)'
    I think it's wrong using ' instead of " within --> new SimpleDateFormat('ddMMyyyy...
    I'm trying different tries ...

    Thanks and regards
    nuvola

  5. #15
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,015

    Default

    You need to fully qualify 'java.text.SimpleDateFormat' and 'java.util.Date' so SpEL can find the classes.
    Last edited by Gary Russell; Apr 26th, 2012 at 06:19 PM.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  6. #16

    Default

    Again thanks!
    It works!

    Code:
    <file:outbound-channel-adapter id="unknownMessageTypeChannel" directory="file:${unknownMessageType.directory}"
           filename-generator-expression="'${myQueue.jndiName}' + '_' + headers['jms_messageId'].replace('&lt;','').replace('&gt;','').replace(':','_') + '_' + new java.text.SimpleDateFormat('ddMMyyyy_HHmmss').format(new java.util.Date()) + '.xml'"/>
    File generated: jms.MyQueue_ID_240478.1335483156383.0_27042012_013 254.xml

  7. #17

    Default

    Ciao Gary,

    I'm adding an errorChannel as in the log I see

    Code:
    27.apr.2012 13:54:26,255 - (MY LISTENER SERVICE) (main) [INFO  ]-[DefaultConfiguringBeanFactoryPostProcessor(120 )] - No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
    I added in my applicationContext.xml

    Code:
    <stream:stderr-channel-adapter channel="errorChannel" append-newline="true" />
    but the above INFO message is still there. I will open a new post on this specific topic for getting some best practices as it is not related directly with current thread on "xml:xpath-router"

    Regards
    nuvola

  8. #18
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,015

    Default

    Just add

    Code:
    <int:channel id="errorChannel"/>
    if you want to avoid that message; but it doesn't hurt anything.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  9. #19
    Join Date
    Dec 2011
    Posts
    13

    Default

    Quote Originally Posted by Gary Russell View Post
    Ahh... change resolution-required to "false". That's what triggers sending messages for unresolved channels to the default-output-channel.
    Thank you, Gary! This was critical as I was trying to hack a solution to not lose unsupported message payloads.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •