0

My questions is as follows: I have a service, which queries the DB and retrieves some records. Then it updates an external system using that information and in the end in updates back the DB.

Using spring trascations and weblogic jta transaction manager i was able with sample code below not to loose any messages in case

  1. No records are retrived. (these are mandatory for the External System)
  2. External System Error
  3. Failed to update the DB

So in all aboce cases the JMS Listener puts the errror message back to the queue.

My question, is there any better way, using Spring with all its goodies, to manage that? The sample code below throws explicilty a RuntimeException which i dont think is a good design...

Please for your comments.

EDIT: The queue is being polled by the submissionListener MDP that its configuration is shown below. After the message is consumed it invokes the registerDocument() of the service. (another Spring bean). That service invokes 2 times the DAO and the external system.

1
  • Your submissionDAO is handling reading from the queue and writing to the DB? Commented Mar 5, 2013 at 15:07

1 Answer 1

1

Check out Spring's documentation on JmsTemplate and Message Driven POJOs for patterns in the core Spring framework.

Spring Integration models higher-level abstractions related to message-orientated patterns.

Sign up to request clarification or add additional context in comments.

2 Comments

Hard to avoid throwing an exception in those cases, unless you went with custom logic to handle returning a failed status. You could throw a custom exception instead that better captures the context of the failure.
I agree with Steve, you cannot avoid throwing an exception - but it would be much better practice to create your own exception with explicit details for your application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.