[jboss-user] [EJB 3.0] - Re: Deployment error mapping a parent/child related entity

2006-07-15 Thread elkner
 = unbound type ...

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3958259#3958259

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3958259
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [Remoting] - Re: thread pool accepting connections

2006-08-11 Thread elkner
BTW: Did you already have a look at grizzly ?

Just in case - ref: 
http://weblogs.java.net/blog/jfarcand/archive/2006/06/tricks_and_tips.html

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3964735#3964735

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3964735
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [EJB 3.0] - Re: Stateful Bean and the database commit

2007-01-17 Thread elkner
"konstantin.ermakov" wrote : Hi!
  | 
  | As far as I understood, after update() it is not guaranteed, that the data 
is in database and commit event already happened. So, as I have the fat clients 
it can be the case, that after update() was called, getObject() still returns 
the old entity.
  | 
  | My question is  - is it guarateed, that after the afterCompletion() method 
the database commit already happened, and it is safe to call getObject() to 
receive the new data?
  | 

I think yes, when you use TXed messages to notify your clients. E.g. here the 
meat (aka main things) how I use it:

  | public class MsgProducer {
  | private static HashMap seq =
  | new HashMap();
  | ...
  | /**
  |  * Simple container for recording queue parameters.
  |  *
  |  * @author  Jens Elkner
  |  * @version $Revision$
  |  */
  | public static class QueueParams {
  | Connection con;
  | Session session;
  | MessageProducer producer;
  | 
  | QueueParams(Connection con, Session session, MessageProducer 
producer) {this.con = con;
  | this.session = session;
  | this.producer = producer;
  | }
  | 
  | void destroy() {
  | if (con != null) {
  | try {
  | con.stop();
  | } catch (JMSException e) {
  | // ignore
  | }
  | }
  | if (session != null) {
  | try {
  | session.close();
  | } catch (JMSException e) {
  | // ignore
  | }
  | }
  | if (con != null) {
  | try {
  | con.close();
  | } catch (JMSException e) {
  | // ignore
  | }
  | }
  | }
  | }
  | 
  |   /**
  |  * Create a message producer for the given destination.
  |  *
  |  * @param destination   topic to use
  |  * @param txwhether to use a transaction scoped session
  |  * @return null on error, the message producer otherwise.
  |  */
  | private static QueueParams createNewSession(String destination, boolean 
tx)
  | {
  |   try {
  | ctx = new InitialContext();
  | // we let the destination decide, whether it is a
  | // Queue- or TopicConnectionFactory
  | ConnectionFactory cf = (ConnectionFactory)
  | ctx.lookup("java:/JmsXA");
  | // create a Connection using the ConnectionFactory (it is not
  | // necessary to start the Connection if messages are only sent)
  | Connection tc = cf.createConnection();
  | // create a Session using the Connection: Transaction +
  | // Auto Acknowledge of the Messages
  | Session s = tc.createSession(tx,
  | tx ? Session.SESSION_TRANSACTED : Session.AUTO_ACKNOWLEDGE);
  | // look up the Destination (either Queue or Topic) to which we 
want
  | // to connect in JNDI
  | Destination dst = (Destination) ctx.lookup(destination);
  | // create a message producer by the session and destination 
acquired
  | // above
  | MessageProducer producer = s.createProducer(dst);
  | if (producer != null) {
  | params = new QueueParams(tc, s, producer);
  | }
  | } catch (Exception e) {
  | log.error(e.getLocalizedMessage());
  | failed = true;
  | }
  | if (failed && params != null) {
  | params.destroy();
  | params = null;
  | }
  | return params;
  | }
  | 
  | /**
  |  * Send a message to the given destination.
  |  *
  |  * @param destination   name of the queue/topic - e.g. "topic/foo" or
  |  *  "queue/bar".
  |  * @param list  list of CRUD events
  |  */
  | public static void send(String destination, CrudEventList list) {
  | if (destination == null || list == null || list.getSize() == 0) {
  | return;
  | }
  | QueueParams q = createNewSession(destination, true);
  | if (q == null) {
  | log.error("Unable to deliver message to '" + destination + "'");
  | return;
  | }
  | try {
  | ObjectMessage m = q.session.createObjectMessage(list);
  | long msgId = getNextId(destination);
  | m.setLongProperty("seq", msgId);
  | if (log.isDebugEnabled()) {
  | log.debug("sending CRUD message " + msgId + " to " + 
destination);
  | }
  |