Announcement Announcement Module
Collapse
No announcement yet.
Do I need a transformer?? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Do I need a transformer??

    I have a situation where I need to get an address from my database and send that in a JMS response in a particular XML format. I have a service activator that deals with this and currently returns the correctly formatted XML for the response

    Code:
    <chain input-channel="getAddressChannel" outputchannel="addressResponseChannel">
        <service-activator ref="addressRequestHandler" />
    </chain>
    	
    <channel id="addressResponseChannel"></channel>
    	
    <jms:outbound-channel-adapter id="jmsAddressResponse" destination-name="Q_ADDRESS_RESPONSE" channel="addressResponseChannel" />
    My question is whether my service activator should return an "Address" object and I should have a transformer to transform it to the correct format for this output channel? That way the service could be used in other contexts and wouldnt be so tightly coupled. Any thoughts anyone?? Or is this over kill??

  • #2
    First of all, this has nothing to do with Spring Integration. SI is not responsible for the content of the message, so SI shouldn't be in your way in that regard.

    Of course it is an interesting question. In my personal opinion any change that has all of the following properties:
    - doesn't give you extra functionality,
    - doesn't decrease the size (*) of your code base and
    - doesn't resolve bugs
    is overengineering.

    You can always do the change later when you actually need it, no?

    (*) people who measure the size of their code base in LOC should not be taken seriously

    Comment


    • #3
      You're right SI certainly isnt in my way, it's my enabler. It's more a question about how best to use it and where the seperation of conerns should lie. I was thinking that my bean that retrieves the address should be concerned with just that rather than retrieval and formatting of the payload.

      I should explain that my previous post was part of a POC I did to prove SI meets our project requirements. I'm now looking how best to use it within an enterprise architecture so it's not really a "change" to existing code, I've got a blank sheet.

      p.s. this is the fastest replying forum ever

      Comment


      • #4
        Originally posted by rhart View Post
        You're right SI certainly isnt in my way, it's my enabler. It's more a question about how best to use it and where the seperation of conerns should lie. I was thinking that my bean that retrieves the address should be concerned with just that rather than retrieval and formatting of the payload.

        I should explain that my previous post was part of a POC I did to prove SI meets our project requirements. I'm now looking how best to use it within an enterprise architecture so it's not really a "change" to existing code, I've got a blank sheet.
        Yes, it sounds like a good idea to separate formatting from business logic, but where you do it exactly (have the service delegate to a formatter, or use a transformer for example) is entirely up to you. You should read "change" in my post more as the difference between two options. In my mind everything I could do to my code is a change and every two pieces of code differ "a change" but that might be a weird concept.

        p.s. this is the fastest replying forum ever
        You should try our support, this is just something we do as a hobby

        Comment


        • #5
          Originally posted by iwein View Post
          You should try our support, this is just something we do as a hobby
          I will when our alliance is in place and it's free

          Comment

          Working...
          X