Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create sync flow with retry mechanism in the middle

 
ray frid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am using Jboss5.1, EJB3.0.

I am developing Webservice.

Each request I am receiving thru this webservice supposed to be procceed and added to another resource(thru another webservice which I will use). that resource sends back a synchronous answer.

Sometimes the webservice which I will use to pass the request could lose connection.

I want to create retry mechanism to ensure after 3 retries I will return a connection failure status.

As we know as soon as I use JMS I lose the synchronous. this flow must be kept synchronized from the beginning.

I know I can implement retry myself. But I would like to use JMS because it's being managed by the container and has more abilities.

Any idea how could I solve this problem?

thanks,

ray.
 
Andrew Moko
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would create a MessageConsumer object from a TemporaryQueue and listen for reply messages.
 
ray frid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,
Could you give me please more details of your solution?
 
Andrew Moko
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ray frid wrote:Hi Andrew,
Could you give me please more details of your solution?


Here's a simple code to get you going.



In this case, dependending on the 'reply', you can choose to resend the message back to the queue or just continue with the proceeding code..

Good luck!
 
ray frid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And it will still keep the whole flow synchronous ?
 
Andrew Moko
Ranch Hand
Posts: 55
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic