null, the call will be ignored)
+ /// The ConnectionFactory that the Connection was obtained from. (may be null)
+ /// whether the Connection might have been started by the application.
+ public static void ReleaseConnection(Connection connection, ConnectionFactory cf, bool started)
+ {
+ if (connection == null)
+ {
+ return;
+ }
+
+ try
+ {
+ connection.Close();
+ } catch (Exception ex)
+ {
+ LOG.Debug("Could not close EMS Connection", ex);
+ }
+ }
+
+ /// null)
+ ///
+ /// whether to allow for a local EMS transaction
+ /// that is synchronized with a Spring-managed transaction (where the main transaction
+ /// might be a ADO.NET-based one for a specific DataSource, for example), with the EMS
+ /// transaction committing right after the main transaction. If not allowed, the given
+ /// ConnectionFactory needs to handle transaction enlistment underneath the covers.
+ ///
+ /// null if none found
+ /// false.
+ /// null if none found
+ /// DoGetTransactionalSession method.
+ /// null if none found
+ /// null if none found
+ /// Note: This is an SPI class, not intended to be used by applications.
+ /// + ///null)
+ ///
+ public EmsResourceHolder(ConnectionFactory connectionFactory)
+ {
+ this.connectionFactory = connectionFactory;
+ }
+
+ /// ConnectionFactory. Binds a
+ /// Connection/Session pair from the specified ConnecctionFactory to the thread,
+ /// potentially allowing for one thread-bound Session per ConnectionFactory.
+ /// ConvertAndSend and ReceiveAndConvert operations.
+ ///
+ /// Converts a String to a EMS TextMessage, a byte array to a EMS BytesMessage, + /// a Map to a EMS MapMessage, and a Serializable object to a EMS ObjectMessage + /// (or vice versa).
+ /// + /// + ///true if the domain is pub-sub, false if P2P
+ ///
+ /// Not intended to be used directly. See EmsTemplate.
+ /// + ///true if the domain is pub-sub, false if P2P
+ ///
+ /// finally blocks in manual EMS code.
+ /// null)
+ ///
+ public static void CloseConnection(Connection con)
+ {
+ CloseConnection(con, false);
+ }
+
+ /// finally blocks in manual EMS code.
+ /// null)
+ ///
+ /// whether to call stop() before closing
+ ///
+ public static void CloseConnection(Connection con, bool stop)
+ {
+ if (con != null)
+ {
+ try
+ {
+ if (stop)
+ {
+ try
+ {
+ con.Stop();
+ }
+ finally
+ {
+ con.Close();
+ }
+ }
+ else
+ {
+ con.Close();
+ }
+ }
+ catch (EMSException ex)
+ {
+ logger.Debug("Could not close EMS Connection", ex);
+ }
+ catch (Exception ex)
+ {
+ // We don't trust the EMS provider: It might throw another exception.
+ logger.Debug("Unexpected exception on closing EMS Connection", ex);
+ }
+ }
+ }
+
+ /// finally blocks in manual EMS code.
+ /// null)
+ ///
+ public static void CloseSession(Session session)
+ {
+ if (session != null)
+ {
+ try
+ {
+ session.Close();
+ }
+ catch (EMSException ex)
+ {
+ logger.Debug("Could not close EMS Session", ex);
+ }
+ catch (Exception ex)
+ {
+ // We don't trust the EMS provider: It might throw RuntimeException or Error.
+ logger.Debug("Unexpected exception on closing EMS Session", ex);
+ }
+ }
+ }
+
+ /// finally blocks in manual EMS code.
+ /// null)
+ ///
+ public static void CloseMessageProducer(MessageProducer producer)
+ {
+ if (producer != null)
+ {
+ try
+ {
+ producer.Close();
+ }
+ catch (EMSException ex)
+ {
+ logger.Debug("Could not close EMS MessageProducer", ex);
+ }
+ catch (Exception ex)
+ {
+ // We don't trust the provider: It might throw an exception .
+ logger.Debug("Unexpected exception on closing EMS MessageProducer", ex);
+ }
+ }
+ }
+
+ /// finally blocks in manual EMS code.
+ /// null)
+ ///
+ public static void CloseMessageConsumer(MessageConsumer consumer)
+ {
+ if (consumer != null)
+ {
+ try
+ {
+ consumer.Close();
+ }
+ catch (EMSException ex)
+ {
+ logger.Debug("Could not close EMS MessageConsumer", ex);
+ }
+ catch (Exception ex)
+ {
+ // We don't trust the EMS provider: It might throw RuntimeException or Error.
+ logger.Debug("Unexpected exception on closing EMS MessageConsumer", ex);
+ }
+ }
+ }
+/*
+ /// finally blocks in manual EMS code.
+ /// null)
+ ///
+ */
+// public static void CloseQueueRequestor(QueueRequestor requestor)
+// {
+// if (requestor != null)
+// {
+// try
+// {
+// requestor.Close();
+// }
+// catch (EMSException ex)
+// {
+// logger.Debug("Could not close EMS QueueRequestor", ex);
+// }
+// catch (Exception ex)
+// {
+// // We don't trust the EMS provider: It might throw RuntimeException or Error.
+// logger.Debug("Unexpected exception on closing EMS QueueRequestor", ex);
+// }
+// }
+// }
+
+
+ ///