Announcement Announcement Module
Collapse
No announcement yet.
JDBC payload to XML message Transformation - Need tips/suggestions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JDBC payload to XML message Transformation - Need tips/suggestions

    Hi Friends,
    I have broken up the issue faced in points below.

    @Gary Russel & David Turanski - Since i have met you both personally, requesting you to kindly have a look


    Aim : Poll a database table and convert the JDBC payload to an Object , Create a XML message using JAXB and post to a JMS queue/topic.

    Approach Tried : - int-jdbc:inbound-channel-adapter to poll the database.
    - int:service-activator to call a utility that transforms the JDBC payload to an Object(simple Pojo class).
    - Pass the Object to the JAXB utility which generates the XML message.
    - Post the message to a JMS queue.

    Issue faced : - Unable to convert the below JDBC payload to an Object.



    Payload recieved in the Service Activator -
    Poll resulted in Message: [Payload=[{DDA_RID_DDA=((AMNG6S, DDA_CDE_PAY_MTD_TP=DDA , DDA_XID_ACCOUNT_NO=2546000000 , DDA_AMT_AMOUNT=2390000.000, DDA_CDE_OWN_BRANCH=DBSG , DDA_CDE_CURRENCY=USD, DDA_CDE_ACCTG_OPER=CR , DDA_DTE_VALUE_DATE=2013-05-14, DDA_DTE_BUS_DATE=2013-05-14, DDA_RID_SVC_GROUP=W(74PQ3X, DDA_RID_CASHFLOW=WCAMMZAJ, DDA_IND_REVERSAL=N, DDA_IND_SBLC=N, DDA_UID_REC_UPDATE=LXXPGCOM, DDA_UID_REC_CREATE=MOHALIK , DDA_TSP_REC_UPDATE=2013-05-14 06:00:14.190623, DDA_TSP_REC_CREATE=2013-05-14 05:48:59.42, DDA_NME_ACCT_NAME=BAYER (SOUTH EAST ASIA) PTE LTD , DDA_CDE_SERVICE=DIDMS, DDA_TXT_TRAN_DESC=COF Initial Drawdown , DDA_RID_OWNER=WCAMMZ68, DDA_PID_DEAL=S777343G, DDA_PID_FACILITY=S777343Q, DDA_NME_DEAL=BAYER (SOUTH EAST ASIA) PTE LTD , DDA_NME_FACILITY=STL UFN MULTI PDT- SGD , DDA_NUM_REV_SEQ=null, DDA_CDE_OWNER=OTR , DDA_CDE_QUEUE_STAT=CONF , DDA_TXT_TO_INFO=null, DDA_NUM_SEQUENCE=null, DDA_TSP_ITEM_SENT=2013-05-14 06:00:14.190623, DDA_TXT_REF_SYS=null, DDA_CDE_PRIORITY=N , DDA_NME_LOAN_ALIAS=H8JAMMZ5R , DDA_DTE_POSTING=2013-05-13}]][Headers={timestamp=1370266733115, id=6eb59a05-616a-4376-8122-90791b0bf5bf}]


    Code Snippets -
    Code:
    <int-jdbc:inbound-channel-adapter 
                    channel="jdbcChannel" data-source="dataSource" max-rows-per-poll="5" 
                    query="select * from ls2db2v.vls_dda_out where dda_rid_cashflow in ('WCAMMZAJ','AMNG6S') and dda_cde_currency in ('SGD')" 
                    update="update ls2db2v.vls_dda_out set dda_cde_currency='USD' where dda_rid_cashflow in ('WCAMMZAJ','AMNG6S') and dda_cde_currency in ('SGD') "> 
            </int-jdbc:inbound-channel-adapter>
    Code:
    <int:service-activator input-channel="jdbcChannel" output-channel="output" 
                    ref="PostPollerService" method="getPayload" />

    Also please let me know if there is a better approach to the above scenario.
    Any help is appreciated.


    Regards,
    PD

  • #2
    Unable to convert the below JDBC payload to an Object.
    It's hard to say when you don't show what the problem is or what you are trying to do to do the conversion.

    The simplest solution to this pattern is to implement a custom RowMapper object and supply it to the adapter using the row-mapper attribute. Then, the POJO will be emitted by the adapter.

    When you don't supply a RowMapper, you get a column/value Map.

    Comment


    • #3
      Hi Gary, Thanks a lot for taking time and responding.

      I'm aware on how to implement the Custom Row Mapper using Spring
      i.e ,

      Code:
      public class MyRowMapper implements RowMapper
      {
      	public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
      		Customer customer = new Customer();
      		customer.setCustId(rs.getInt("CUST_ID"));
      		customer.setName(rs.getString("NAME"));
      		customer.setAge(rs.getInt("AGE"));
      		return customer;
      	}
       
      }

      How can i implement the same in Spring Integration ?

      - Add rowmapper reference to the int-jdbc:inbound-channel-adapter i.e row-mapper="rowMapper"
      <bean id="rowMapper" class="com.hcl.MyRowMapper"></bean>

      - Then the reference bean needs to implement RowMapper<PojoClass> ?



      Appreciate if you can provide any links or samples for the same.
      Last edited by Gary Russell; Jun 12th, 2013, 05:02 AM.

      Comment


      • #4
        Please use [CODE], not [QUOTE] when posting code/config (I edited your post).

        Exactly correct; see the reference document and the schema documentation for the row mapper attribute.

        The JDBC Sample Application uses a PersonMapper RowMapper.

        Comment


        • #5
          Thanks for the Edit and help Gary
          Issue Resolved! Appreciate your help and time.

          Regards,
          PD

          Comment

          Working...
          X