Results 1 to 2 of 2

Thread: Best way to delete from a table and then insert?

  1. #1

    Default Best way to delete from a table and then insert?

    I have a requirement where on receipt of a JMS message I need to delete all the data from a table before repopulating with the data in the message. It's very important that the deletes occur first and I'd like the pipeline structure to capture this. I'd also like to make use of the jdbc support in SI .

    I've tried using a <wiretap> to send the message to <jdbc:outbound-adapter> to perform the delete but I'm not sure if this is in the spirit of the wiretap or if there is a guarentee that the <wiretap> flow will always execute before any of the handlers attached to the 'tapped channel.

    I might be able to use the <jdbc:outbound-gateway/> to perform the deletes but I need to return the original payload so I can pass onto the next processing step - I dont really care about the number of rows deleted. I can add the orginal payload as a header for later use and this is what I will do, but I wondered if there was a better way of doing this? (I quite often find that I need to invoke a single component, or a sub-flow, but on success of that component or flow I want to continue with the original message and I resort to putting the payload into a header for later use)

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,147

    Default

    Wiretap is not really intended for "core" functionality such as this.

    There are (at least) two approaches you could use...

    1. Use a <recipient-list-router/> where the same message is sent to each recipient, in order, on the same thread.
    2. Use a <publish-subscribe-channel /> and set the order attribute on the endpoints to specify the order in which you want them to receive the message. Again, by default, these sends will occur on the same thread.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

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