Results 1 to 10 of 13

Thread: query for not losing the message

Hybrid View

  1. #1
    Join Date
    Sep 2011
    Posts
    167

    Exclamation query for not losing the message

    Hi,
    I have a query , I am currently developing an application in which my I will read the data from the queue and will put
    the data on the channel, that I am doing through message listener in spring integration and after that a file need to
    be get created reading the message from that channel , That also I am doing through file generator in spring
    integration.

    Now for audit purpose I want while reading the message from the queue it should also be stored in database first and after
    that it should go for file creation.But in the scenerio let say if file doesn't get created in the end succesfully then
    in that case the message to be deleted means rollback from datbase and also that message again to be sent in to the
    queue again , what I was trying to achieve that message should not be lost, please guide me how to proceed for this scenerio..!!
    Thanks in advance...!

  2. #2
    Join Date
    Sep 2011
    Posts
    167

    Default

    Quote Originally Posted by SARAL SAXENA View Post
    Hi,
    I have a query , I am currently developing an application in which my I will read the data from the queue and will put
    the data on the channel, that I am doing through message listener in spring integration and after that a file need to
    be get created reading the message from that channel , That also I am doing through file generator in spring
    integration.

    Now for audit purpose I want while reading the message from the queue it should also be stored in database first and after
    that it should go for file creation.But in the scenerio let say if file doesn't get created in the end succesfully then
    in that case the message to be deleted means rollback from datbase and also that message again to be sent in to the
    queue again , what I was trying to achieve that message should not be lost, please guide me how to proceed for this scenerio..!!I need to use transcation managers jta also for that......!!
    Thanks in advance...!
    Hi ,
    please advise me on this as I m currently using Apache Active MQ and I want to test it as a stand alone application..and I want to use JTA trnscation managers for that .!!
    Last edited by SARAL SAXENA; Nov 16th, 2011 at 10:26 AM.

  3. #3
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    Quote Originally Posted by SARAL SAXENA View Post
    Hi ,
    please advise me on this as I m currently using Apache Active MQ and I want to test it as a stand alone application...!!
    You are looking for distributed transaction where reading from the queue and update to the database happens in a transaction.
    You can have a message-driven-channel-adapter followed by a chain of an audit service activator and a file:outbound-channel-adapter as below.



    <!-- Direct Channels -->

    <integration:channel id="inChannel"/>
    <integration:channel id="outChannel"/>

    <!-- To receive messages over MQ -->
    <jms:message-driven-channel-adapter destination="someDestination" channel="inChannel" transaction-manager="txMgr"/>

    <integration:chain input-channel="inChannel" output-channel="outChannel">
    <integration:service-activator ref="auditBean" method="auditInDatabase"/>
    <file:outbound-channel-adapter directory="${output.directory}"/>
    </integration:chain>
    Your service activator will return the same message as that is passed to it's auditInDatabase method. If all goes file you will get a java.io.File payload in the message over the outChannel. If an exception is thrown in creating the file, the transaction will be rolled back and based on the redelivery policies of the Active MQ, the message will be redelivered.

  4. #4
    Join Date
    Sep 2011
    Posts
    167

    Default

    Quote Originally Posted by Amol Nayak View Post
    You are looking for distributed transaction where reading from the queue and update to the database happens in a transaction.
    You can have a message-driven-channel-adapter followed by a chain of an audit service activator and a file:outbound-channel-adapter as below.





    Your service activator will return the same message as that is passed to it's auditInDatabase method. If all goes file you will get a java.io.File payload in the message over the outChannel. If an exception is thrown in creating the file, the transaction will be rolled back and based on the redelivery policies of the Active MQ, the message will be redelivered.

    Hi Amol Nayak,

    Thanks a lot for this creative idea , this is what some where near to my imagination about the service activator what I was planning that service activator should have the code of inserting the message into the database in other words
    it will have the buisness logic of spring jdbc template and after that file creation process will start up
    and in file the same message will be writtenif some how because of any reason the file doesn't get created
    then in that case the same message should be removed from database and the same message should go again back to queue, message should not be lost
    so I need to two transcation managers for that one is of jdbc and other is of jms specific that will controls the message flow
    I am configuring my queue on apache active mq.

    please can you explain about the integration chain component and it's functionality ...in spring integration..!!
    and other thing is that about the redelivery policies of the Active MQ./.what are those policies..?

  5. #5
    Join Date
    Sep 2011
    Posts
    167

    Default

    Quote Originally Posted by Amol Nayak View Post
    You are looking for distributed transaction where reading from the queue and update to the database happens in a transaction.
    You can have a message-driven-channel-adapter followed by a chain of an audit service activator and a file:outbound-channel-adapter as below.





    Your service activator will return the same message as that is passed to it's auditInDatabase method. If all goes file you will get a java.io.File payload in the message over the outChannel. If an exception is thrown in creating the file, the transaction will be rolled back and based on the redelivery policies of the Active MQ, the message will be redelivered.



    Hi Amol Nayak,

    Thanks a lot for this creative idea , this is what some where near to my imagination about the service activator what I was planning that service activator should have the code of inserting the message into the database in other words
    it will have the business logic of spring jdbc template and after that file creation process will start up
    and in file the same message will be written if some how because of any reason the file doesn't get created
    then in that case the same message should be removed from database and the same message should go again back to queue, message should not be lost so I need to two transaction managers for that one is of jdbc and other is of jms specific that will controls the message flow I am configuring my queue on apache active mq.

    please can you explain about the integration chain component and it's functionality ...in spring integration..!!
    and other thing is that about the redelivery policies of the Active MQ.!!.what are those policies..?

  6. #6
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    then in that case the same message should be removed from database and the same message should go again back to queue, message should not be lost
    Message is not put in database. It will be a normal insert that would insert into the audit table some attributes of the message, some other derived values or some application specific values, this could be done using plain old JDBC, use spring's JDBC template.

    The adapter provided by the MQ vendor is responsible for participating in the global transaction and according handle the de queuing of messages, redelivering the message (JMS Message) back in case of transaction rollback etc.

    so I need to two transaction managers for that one is of jdbc and other is of jms
    No, you use one JTA transaction manager.

    please can you explain about the integration chain component and it's functionality ...in spring integration..!!
    Spring integration has an easy to understand and helpful reference manual, the Message Handler Chain is explained here

    and other thing is that about the redelivery policies of the Active MQ.!!.what are those policies..?
    Search for Active MQ documentation, you should find it there.

  7. #7
    Join Date
    Sep 2011
    Posts
    167

    Default

    Quote Originally Posted by Amol Nayak View Post
    Message is not put in database. It will be a normal insert that would insert into the audit table some attributes of the message, some other derived values or some application specific values, this could be done using plain old JDBC, use spring's JDBC template.

    The adapter provided by the MQ vendor is responsible for participating in the global transaction and according handle the de queuing of messages, redelivering the message (JMS Message) back in case of transaction rollback etc.


    No, you use one JTA transaction manager.



    Spring integration has an easy to understand and helpful reference manual, the Message Handler Chain is explained here



    Search for Active MQ documentation, you should find it there.

    Hi Anmol,
    Thanks ,I have configured the settings as guided by you, please guide me how to configure the settings for transcation managers in the xml file , I want to configure the JTA specifice settings in this configuration file with respect to Apache Active Mq.

Posting Permissions

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