Cainiao Zou

Ranch Hand
+ Follow
since Mar 03, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Cainiao Zou

In compare with Stateless Session Bean (SLSB), there are many limitations on MesageDrivenBean (MDB). I met a problem now:

In the onMessage function of my MDB, I do some job about Database (with help of a SLSB DAO, TransactionType is Require), after that I send the reponse message back. But I got a problem because I try to update database and send message in the same tranaction, which should be two-phase commit. I use HSQLDB inside JBoss, it doesn't support the two-phase commit. So I have to separate the database operation and send message operation in two different transaction. The question is how?

Should I make another SLSB, only for sending message? Or I have to change the TransactionType of DAO to Require_New?
Is there any better solution?

thanks.
omg, i have the same problem. Is there any answer?
HTTPSession is a high level interface built on top of cookie and url-rewriting, that means there is only a session id stored in client, the relative big data are stored in server.
I'm not talking about how to save data with HTTPSession interface. I'm just wondering where are the data actually stored in server? In the memory or somewhere?
How can I change the place to store, e.g. I want to save them into a in-memory database, how could I do that?
Btw, if it's not in a database, is there any concurrency problem when many client work on a same session data at the same time?

thanks
8 years ago

ntumba lobo wrote:Whether to use a dynamic queue or not to me depends on the calling thread.

If the calling thread, the one sending the request message in the input queue, needs the response message message
from the output queue to carry on its processing then you would need a temporary queue output queue.
This is akeen to a synchronous communication.
On the other hand if the response from the output queue can be process in a separate thread a pair of static queues with
selective consumers on the output queue would more suitable. This is real asynchronous communication.

my 2 cts



thanks for your answer.
no, the calling thread don't need the response, it's asynchronous.
how about the performance, is it ok for two queues? how about the output queue, should i use topic instead?
take a look at the jndi-viewer in jmx console. it's a very handy tool in jboss. just type http://localhost:8080 in browser and you can find it in menu.
I’m writing a server/client game, a typical scenario looks like this: one client (clientA) send a message to the server, there is a MessageDrivenBean in server to handle such messages. After the MDB finished its job, it sends the result message back to another client (clientB).

In my opinion I only need two queues for such communication, one for input the other for output. Creating new queue for each connection is not a good idea, right? The Input queue is relative clear, if more clients are sending message at the same time, the messages are just waiting in the queue, while there are more MDB instances in server, that should not a big performance issue.

But on the other side I am not quite clear about the output queue, should I use a topic instead of a queue? Every client is listening the output queue, one of them gets the new message and checks the property to determine if the message is to it, if not, it rollback the transaction, the message goes back to queue and be ready for other client … It should work but must be very slow. If I use topic instead, every client gets a copy of the message, if it’s not to it, just ignores the message. It should be better, right?

I’m new about message system. Is there any suggestion about my implementation? Thanks!
Hi everybody.

I'm trying to make a plugin-based application which means, besides the basic framework, other functionalities should be added with a plugin style.

The majar problem of such system, i think, is how to load new plugins at the runtime. I don't want to recomplie the whole project when a new plugin installed. Just like Eclipse, after new installation of plugin, the user only need to restart it.
So my first idea about that is using java reflection to load the class at the runtime. there might be some plugin configuration files, the system reads them and load the plugin classes with reflection. Maybe i can use the spring framework as well, because its Inversion of Control is just match my request.

Another idea i'm investigating is using the ejb container. when the plugins are ejbs, i can just pack them into jar and deploy them in an ejb container, then i can use jndi to access them. but it only works when the plugin are ejbs.

anyway, i'm a rookie in system design. so i post this topic and want to hear of your opinions.
btw. is there any good book about system design you want to recommand?

thanks alot in advance!
I'm using Ant 1.7, want to copy files from different paths (they have no relationship, so i cannot use the include selector to filter them out of their root directory). I try to use the <path> inside the <copy> instead of <fileset>, because with <path> i can specify multi paths which is in <fileset> not possible. My ant script looks like this, but it doesn't work.



Anybody has idea about how to use the <path> inside <copy>? Or maybe anybody has the advise about how to copy files from different source without selector?

Btw, i don't want to hard code the source directories, they will be read from a propertiy file, so writing multi <fileset> inside <copy> should not be considered.

thanks in advance!
9 years ago
which annotation injections can be extends by the subclass?
@Resource
@EJB
btw, the properties are public/protected
Session Beans have a lifecycle callback function @PostConstruct, it's different than the class constructor, because it will be called later after dependence injection.
So my question is, can man call another EJB which is injected with @EJB in this lifecycle function and if yes, how about the transaction propagation? (JTA, CMT, transactional persistence context)

thanks
Hi, i'm reading a description about transaction in MDB (the book "Enterprise JavaBeans 3.0" from O'Reilly)



In my opinion, in MDB we shouldn't use the transaction attribute which has a relation with caller/client, because MDB is "message driven", so we just lost some informations about the client. And that's what it should be.

But why Required transaction attribute is allowed here? It will use the old transaction of client if there is one, am I right? And why not RequiredNew, it just create a new transaction no matter the situation of the client.

Is that an error of this book or i don't understand correctly?

thanks
I have a entity "User", and i just create it and try to persist it, but I got a error message, something like i was persisting a detached Entity.
I checked the code of "User", i found there was no auto generated id property like other entities, the identity is the "name" property, which must be initialed by creating. Then I added the "dummy" id property just like normal, all work fine!

So I just wonder, why JPA/Hibernate said it was a detached Entity at all? I guess, it just checks the identity property of the entity, if it's not NULL (dummy ids are almost always null by creating and will be auto generated), and there is no copy in PersistenceContext with the same identity, then it will be considered as detached?

Am I right? But what about the situation, when i don't want to use the auto generated identity? How can I persist them?

thanks
Hi,

we are running a tomcat application using Hibernate to access to an mysql database and have the problem about the performance using it.

When enabling the hibernate_statistics it shows that database queries in average takes about 20 till 30 ms using hibernate. But the mysql-log shows that they only takes about 1 ms. Are 20 ms slow for hibernate; what are normal values?

And especially the method getRoles() (in Code 'Entitiy-Bean') takes about 50 ms when tracking the time in the code programmatly and hibernate do not log any database access for it. So what's wrong? The XML-Configuration for hibernate is attached too.

And maybe have someone any tips for improving the hibernate performance with tuning the hibernate properties shown below (code 'Hibernate and c3p0 (datasource) configurations')?

We are happy about any idea. Thanks.

Entity-Bean:


Hibernate and c3p0 (datasource) configurations:

James Sutherland wrote:JPA 1.0 did not require support for nested Embeddables, but JPA 2.0 does support it.

See,

http://en.wikibooks.org/wiki/Java_Persistence/Embeddables#Nesting

So depends on your JPA provider, and what version it supports.

An Embeddable does not need to be serializable, unless you intend to serialize it.



thank you very much
I think the enum must be allways used with the enum class qualifier, for example
MyEnum x = MyEnum.ABC // correct
MyEnum x = ABC // incorrect

But there is a exception in switch, the enum must not be qualified there, for example
switch(x) {
case ABC: ... // correct
case MyEnum.ABC: ... // incorrect
}

Is there any other exceptions about the qualified enum?
thanks