Results 1 to 4 of 4

Thread: How to ignore certain messages in payload-type-router?

  1. #1
    Join Date
    Sep 2012
    Posts
    3

    Default How to ignore certain messages in payload-type-router?

    Hey all,

    I have a certain situation, where all the database updates get posted to a publish-subscribe-topic, which in turn has a few subscribers. I would like to handle all the known types that might be posted to the topic, and ignore the rest, but I have a problem configuring the router - the messages that should be ignored are propagating the exceptions instead of ignoring them. I would expect that resolution-required="false" would ignore the messages that don't have corresponding routing rules:

    Code:
     Specify whether channel names must always be successfully resolved
                        to existing channel instances.
    
                        If set to 'true', a MessagingException will be raised in case
                        the channel cannot be resolved. Setting this attribute to 'false',
                        will cause any unresovable channels to be ignored.
    
                        If not explicitly set, 'resolution-required' will
                        default to 'true'.
    or at least
    default-output-channel="dev-null" ignore-send-failures="true"
    Code:
    If set to "true", failures to send to a message channel will
    					be ignored. If set to "false", a MessageDeliveryException will be
    					thrown instead, and if the router resolves more than one channel,
    					any subsequent channels will not receive the message.

    None of which are the case. Any insights or suggestions would be welcome!

    Code:
        <int:payload-type-router input-channel="database-update-topic" resolution-required="false" default-output-channel="dev-null" ignore-send-failures="true">
            <int:mapping type="com.ajaxoid.domain.shared.PricingRule" channel="pricing-rule-update-channel" />
            <int:mapping type="com.ajaxoid.domain.shared.Product" channel="product-update-channel" />
            <int:mapping type="com.ajaxoid.domain.shared.Vendor" channel="vendor-update-channel" />
            <int:mapping type="com.ajaxoid.domain.shared.Category" channel="category-update-channel" />
        </int:payload-type-router>
    
        <int:outbound-channel-adapter id="pricing-rule-update-channel" ref="pricingRuleManager" method="pricingRuleUpdated"/>
        <int:outbound-channel-adapter id="product-update-channel" ref="pricingRuleManager" method="productUpdated"/>
        <int:outbound-channel-adapter id="vendor-update-channel" ref="pricingRuleManager" method="vendorUpdated"/>
        <int:outbound-channel-adapter id="category-update-channel" ref="pricingRuleManager" method="categoryUpdated"/>
    
        <int:logging-channel-adapter channel="dev-null"/>
        <int:channel id="dev-null"/>

    regards,
    --andrius aka phuqit

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    The resolution-required="false" means that if specified channel name can not be resolved to an actual instance the resolution failure will be ignored.
    However in your case what you probably want is to simply ignore un-Mappable routes which you can accomplish with default-output-channel="nullChannel" where 'nullChannel' is the name of the channel created automatically by the framework and is an instance of NullChannel which semantically equivalent to dev-null

  3. #3
    Join Date
    Sep 2012
    Posts
    3

    Default

    Quote Originally Posted by oleg.zhurakousky View Post
    you can accomplish with default-output-channel="nullChannel" where 'nullChannel' is the name of the channel created automatically by the framework and is an instance of NullChannel which semantically equivalent to dev-null

    Thank you Oleg - that did the trick!

    Here's another question then, I tried using an aggregator in order to pool messages into blocks instead of spaming the client-push interface with standalone messages, which works just fine, except the SpEL expression to correlate the messages, I ended up using a header-enricher instead:

    <int:header-enricher id="correlation-header-enricher" input-channel="database-update-topic"
    output-channel="enriched-with-correlation-id">
    <int:correlation-id expression="payload.ENTITY_CODE"/>
    </int:header-enricher>


    because specifying

    <int:aggregator id="database-update-pooler"
    input-channel="enriched-with-correlation-id"
    output-channel="document-update-event-publisher"
    release-strategy-expression="#this.size() > 20"
    send-partial-result-on-expiry="true"
    expire-groups-upon-completion="true"
    send-timeout="1000"
    message-store="messageStore"
    />
    with
    correlation-strategy-expression="payload.ENTITY_CODE"

    attribute was picking up a message *list* instead of the actual message being accepted into aggregator as payload. Is this the expected behavior?
    I'm using <spring-integration.version>2.1.0.RELEASE</spring-integration.version>, just in case.

    regards,
    --andrius aka phuqit

  4. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    I think you are looking for something similar to what I showed at SpringOne last year. Take a look at this sample and let me know https://github.com/olegz/s12gx.2011/...ion/aggregator
    Last edited by oleg.zhurakousky; Oct 1st, 2012 at 06:00 PM.

Posting Permissions

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