Combination of JPA entity and Message Driven Bean

I want to create an entity bean which will pick some data from Topic on JMS Server and also some from database. JMS is publish and subscribe mode. And Persistence is from an RDBMS server.

I want to know if it is feasible or not.
How would its sequence and class diagram look like?
If so what are the limitations of this architecture?
jgdvishnuSoftware ArchitectAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jgdvishnuSoftware ArchitectAuthor Commented:
To give more insight on this.

I have trading website and there is Asset Table(or Entity) which stores list of companies and and type of asset such as (share/stock/Mutual Fund/Bonds).

We need to get the price for that asset from a JMS Topic and display to the user. So is there a way that the JPA Entity can also act as JMS Consumer or not.

What is the best way for the asset entity to fetch the Price from JMS Server.
0
Jim CakalicSenior Developer/ArchitectCommented:
To answer your question directly, there isn't anything that prevents you from having non-persistence methods in your entity class. Assuming you have a persistent Asset class you could theoretically code a getPrice method that creates a TopicConnection, a TopicSession and a TopicSubscriber to receive messages.

But I have the feeling I'm missing something here because I don't quite understand how you will "get the price for that asset from a JMS Topic". A Topic isn't a query mechanism. What I'm suspecting is that there is already a JMS Topic in existence where Asset prices are published for interested subscribers. Is that right? If so then what I think you want here is not for your entity class to try to interact with JMS directly but to have a separate JMS component in your design that subscribes to the Topic, receives the messages and stores the information somewhere (like the same Asset database) so that it can be retrieved through normal entity relationship navigation.

If you can fill in some of the gaps here I might be able to provide better assistance.

Regards,
Jim
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jgdvishnuSoftware ArchitectAuthor Commented:
Correct my understanding:-


I had the feeling that Message Driven Bean(MDB - Object) and Entity( EB -persistent object) are managed by application server separately in different pools.

If I mix both MDB and EB class feature into one class then I will not be using the application server's pool of objects feature.

Now to answer your question:-
Yes.  Asset prices are published for all stocks through a topic and I need to know the price for one or two of the shares at a time. Thus there is a need to persist the prices and query for that share.


The JMS Topic server will publish the new prices of all the stocks every few seconds and to store that in my local database and query them and then send to user the latest stock price will result in showing stale data as well as need to maintain huge database for storing transient stock data.

To have the best of both worlds I thought that I will put listeners on Asset entity and filter the message without storing the price all in real time.
0
jgdvishnuSoftware ArchitectAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 500 points for jim_cakalic's comment #a37331569
Assisted answer: 0 points for jgdvishnu's comment #a37394900

for the following reason:

I feel that for some  part my understanding is correct.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.