[jboss-svn-commits] JBL Code SVN: r30999 - in labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration: msg and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Jan 9 03:25:36 EST 2010
Author: kevin.conner at jboss.com
Date: 2010-01-09 03:25:36 -0500 (Sat, 09 Jan 2010)
New Revision: 30999
Modified:
labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/AbstractJmsJobService.java
labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/msg/JmsMessageService.java
labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/msg/JmsMessageServiceFactory.java
labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/timer/JmsSchedulerService.java
labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/timer/JmsSchedulerServiceFactory.java
Log:
Defer creation of connection/session until first use: JBESB-3107
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/AbstractJmsJobService.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/AbstractJmsJobService.java 2010-01-09 05:49:18 UTC (rev 30998)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/AbstractJmsJobService.java 2010-01-09 08:25:36 UTC (rev 30999)
@@ -24,6 +24,7 @@
import java.io.Serializable;
import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -60,52 +61,48 @@
protected final Logger log = Logger.getLogger(getClass()) ;
/**
- * Job session associated with this context.
+ * The current jBPM context.
*/
- JobSession jobSession ;
+ private JbpmContext jbpmContext ;
/**
+ * JMS connection factory.
+ */
+ private ConnectionFactory connectionFactory ;
+ /**
* JMS connection for delivery.
*/
- Connection connection ;
+ private Connection connection ;
/**
* JMS session for delivery.
*/
- Session session ;
+ private Session session ;
/**
* JMS destination for delivery.
*/
- Destination destination ;
+ private Destination destination ;
/**
* JMS message producer for delivery.
*/
- MessageProducer messageProducer ;
+ private MessageProducer messageProducer ;
/**
* Flag indicating that commit should be invoked.
*/
- boolean isCommitEnabled ;
+ private boolean isCommitEnabled ;
/**
* Construct the base JMS job service.
* @param jbpmContext The current jBPM context.
- * @param connection The associated JMS connection.
+ * @param connectionFactory The associated JMS connection factory.
* @param destination The JMS destination for jobs.
* @param isCommitEnabled true if commit should be invoked, false otherwise.
* @throws JMSException For errors in constructing the JMS session.
*/
- public AbstractJmsJobService(final JbpmContext jbpmContext, Connection connection, Destination destination, boolean isCommitEnabled) throws JMSException {
- this.jobSession = jbpmContext.getJobSession();
+ public AbstractJmsJobService(final JbpmContext jbpmContext, ConnectionFactory connectionFactory, Destination destination, boolean isCommitEnabled) {
+ this.jbpmContext = jbpmContext ;
+ this.connectionFactory = connectionFactory ;
- this.connection = connection;
this.destination = destination;
this.isCommitEnabled = isCommitEnabled;
- /*
- * If the connection supports XA, the session will always take part in the global transaction.
- * Otherwise the first parameter specifies whether message productions and consumptions
- * are part of a single transaction (TRUE) or performed immediately (FALSE).
- * Messages are never meant to be received before the database transaction commits,
- * hence the transacted is preferable.
- */
- session = connection.createSession(true, Session.SESSION_TRANSACTED);
}
/**
@@ -136,9 +133,9 @@
}
// Force initialisation of any proxy, JBESB-2720
Hibernate.initialize(job) ;
- jobSession.saveJob(job);
+ getJobSession().saveJob(job);
try {
- Message message = session.createMessage();
+ Message message = getSession().createMessage();
if (job.getToken()!=null) {
message.setLongProperty("tokenId", job.getToken().getId());
}
@@ -164,7 +161,7 @@
}
/**
- * Cloase the job service.
+ * Close the job service.
*/
public void close() {
JbpmException exception = null;
@@ -209,6 +206,7 @@
}
if (exception!=null) {
+ log.debug("Exception during close", exception) ;
throw exception;
}
}
@@ -217,7 +215,23 @@
* Get the JMS session associated with this job service.
* @return The JMS session.
*/
- public Session getSession() {
+ public Session getSession() throws JMSException {
+ if (connection == null) {
+ log.debug("Creating connection") ;
+ connection = connectionFactory.createConnection() ;
+ }
+
+ if (session == null) {
+ log.debug("Creating session") ;
+ /*
+ * If the connection supports XA, the session will always take part in the global transaction.
+ * Otherwise the first parameter specifies whether message productions and consumptions
+ * are part of a single transaction (TRUE) or performed immediately (FALSE).
+ * Messages are never meant to be received before the database transaction commits,
+ * hence the transacted is preferable.
+ */
+ session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ }
return session;
}
@@ -226,7 +240,7 @@
* @return The job session.
*/
public JobSession getJobSession() {
- return jobSession;
+ return jbpmContext.getJobSession();
}
/**
@@ -236,7 +250,7 @@
*/
protected MessageProducer getMessageProducer() throws JMSException {
if (messageProducer==null) {
- messageProducer = session.createProducer(destination);
+ messageProducer = getSession().createProducer(destination);
}
return messageProducer;
}
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/msg/JmsMessageService.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/msg/JmsMessageService.java 2010-01-09 05:49:18 UTC (rev 30998)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/msg/JmsMessageService.java 2010-01-09 08:25:36 UTC (rev 30999)
@@ -21,7 +21,7 @@
*/
package org.jboss.soa.esb.services.jbpm.integration.msg;
-import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -40,13 +40,13 @@
/**
* Construct the JMS message service.
- * @param connection The JMS connection.
+ * @param connectionFactory The associated JMS connection factory.
* @param destination The JMS destination.
* @param isCommitEnabled true if commit is to be invoked, false otherwise.
* @throws JMSException For JMS errors.
*/
- public JmsMessageService(Connection connection, Destination destination, boolean isCommitEnabled) throws JMSException {
- super(getJbpmContext(), connection, destination, isCommitEnabled) ;
+ public JmsMessageService(ConnectionFactory connectionFactory, Destination destination, boolean isCommitEnabled) throws JMSException {
+ super(getJbpmContext(), connectionFactory, destination, isCommitEnabled) ;
}
/**
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/msg/JmsMessageServiceFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/msg/JmsMessageServiceFactory.java 2010-01-09 05:49:18 UTC (rev 30998)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/msg/JmsMessageServiceFactory.java 2010-01-09 08:25:36 UTC (rev 30999)
@@ -21,7 +21,6 @@
*/
package org.jboss.soa.esb.services.jbpm.integration.msg;
-import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -242,8 +241,7 @@
{
try
{
- Connection connection = getConnectionFactory().createConnection();
- return new JmsMessageService(connection, getDestination(), isCommitEnabled);
+ return new JmsMessageService(getConnectionFactory(), getDestination(), isCommitEnabled);
}
catch (JMSException e)
{
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/timer/JmsSchedulerService.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/timer/JmsSchedulerService.java 2010-01-09 05:49:18 UTC (rev 30998)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/timer/JmsSchedulerService.java 2010-01-09 08:25:36 UTC (rev 30999)
@@ -1,6 +1,6 @@
package org.jboss.soa.esb.services.jbpm.integration.timer;
-import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -26,16 +26,16 @@
/**
* Create the JMS scheduler service.
* @param jbpmContext The current jBPM context.
- * @param connection The associated JMS connection.
+ * @param connectionFactory The associated JMS connection factory.
* @param destination The JMS destination for jobs.
* @param isCommitEnabled true if commit should be invoked, false otherwise.
* @throws JMSException For errors in constructing the JMS session.
*/
- public JmsSchedulerService(final JbpmContext jbpmContext, final Connection connection,
+ public JmsSchedulerService(final JbpmContext jbpmContext, final ConnectionFactory connectionFactory,
final Destination destination, boolean isCommitEnabled)
throws JMSException
{
- super(jbpmContext, connection, destination, isCommitEnabled) ;
+ super(jbpmContext, connectionFactory, destination, isCommitEnabled) ;
}
/**
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/timer/JmsSchedulerServiceFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/timer/JmsSchedulerServiceFactory.java 2010-01-09 05:49:18 UTC (rev 30998)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/integration/timer/JmsSchedulerServiceFactory.java 2010-01-09 08:25:36 UTC (rev 30999)
@@ -21,7 +21,6 @@
*/
package org.jboss.soa.esb.services.jbpm.integration.timer;
-import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -141,9 +140,8 @@
{
try
{
- final Connection connection = getConnectionFactory().createConnection();
return new JmsSchedulerService(JbpmConfiguration.getInstance().getCurrentJbpmContext(),
- connection, getDestination(), isCommitEnabled);
+ getConnectionFactory(), getDestination(), isCommitEnabled);
}
catch (JMSException e)
{
More information about the jboss-svn-commits
mailing list