venk somis

Greenhorn
+ Follow
since Jul 02, 2012
Merit badge: grant badges
For More
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 venk somis


May not understand your question properly, why someone wants to use a Static variable in Ejb ? You want have that in Stateless bean ? What is the purpose , One of the very important features that EJB-Container

provided is Thread-safety. So if you use Static in your EJBs, those are not Thread Safe.

One more thing, if you are looking for having some Singleton Classes in EJB layer, you can have that with latest EJB 3.1


The following bean load data in init() method and saves the data when destroyed

@Singleton
public class YourTestBean {
@PersistenceContext
private EntityManager entityManager;
private Rate rate;
@PostConstruct
private void init() {
rate = entityManager.find(Rate.class, 1);
}
@PreDestroy
private void destroy() {
entityManager.merge(rate);
}
public void setRate(Rate rate) {
this.rate = rate;
}
public Rate getRate() {
return rate;
}
}



If you want to capture some flag which indicates you that the given message is Consumed, meaning you are trying to make a semi Request-Response call.

Sending HTTPSession with Message that would not help you, because both are in two different layers and also JMS is an ASYNC process so response will not be
immediate as the actualy task will be performed in different Thread .

So in order to address this issue, you need to create Temparary Queues to which consumer would Respond, and the message filter could be done based on CorrelationId.

Following API could be used.

replyMessage.getJMSCorrelationID());
requestMessage.setJMSReplyTo(replyQueue);


Please see more details below.

http://javaquicknotes.com/questionDelegator/JMS_Request_Response_example

Or
Just see in other java resources for sample.