org.springframework.jms.connection.JmsResourceHolder Java Examples
The following examples show how to use
org.springframework.jms.connection.JmsResourceHolder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BatchedJmsTemplate.java From jadira with Apache License 2.0 | 5 votes |
/** * Determines receive timeout, using logic equivalent to that of {@link JmsTemplate#doReceive(Session, MessageConsumer) * @return The timeout determined */ private long determineTimeout() { long timeout = getReceiveTimeout(); JmsResourceHolder resourceHolder = (JmsResourceHolder) TransactionSynchronizationManager .getResource(getConnectionFactory()); if (resourceHolder != null && resourceHolder.hasTimeout()) { timeout = Math.min(timeout, resourceHolder.getTimeToLiveInMillis()); } return timeout; }
Example #2
Source File: AbstractPollingMessageListenerContainer.java From java-technology-stack with MIT License | 5 votes |
/** * This implementation checks whether the Session is externally synchronized. * In this case, the Session is not locally transacted, despite the listener * container's "sessionTransacted" flag being set to "true". * @see org.springframework.jms.connection.JmsResourceHolder */ @Override protected boolean isSessionLocallyTransacted(Session session) { if (!super.isSessionLocallyTransacted(session)) { return false; } JmsResourceHolder resourceHolder = (JmsResourceHolder) TransactionSynchronizationManager.getResource(obtainConnectionFactory()); return (resourceHolder == null || resourceHolder instanceof LocallyExposedJmsResourceHolder || !resourceHolder.containsSession(session)); }
Example #3
Source File: JmsTemplate.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Actually receive a JMS message. * @param session the JMS Session to operate on * @param consumer the JMS MessageConsumer to receive with * @return the JMS Message received, or {@code null} if none * @throws JMSException if thrown by JMS API methods */ protected Message doReceive(Session session, MessageConsumer consumer) throws JMSException { try { // Use transaction timeout (if available). long timeout = getReceiveTimeout(); JmsResourceHolder resourceHolder = (JmsResourceHolder) TransactionSynchronizationManager.getResource(getConnectionFactory()); if (resourceHolder != null && resourceHolder.hasTimeout()) { timeout = Math.min(timeout, resourceHolder.getTimeToLiveInMillis()); } Message message = doReceive(consumer, timeout); if (session.getTransacted()) { // Commit necessary - but avoid commit call within a JTA transaction. if (isSessionLocallyTransacted(session)) { // Transacted session created by this template -> commit. JmsUtils.commitIfNecessary(session); } } else if (isClientAcknowledge(session)) { // Manually acknowledge message, if any. if (message != null) { message.acknowledge(); } } return message; } finally { JmsUtils.closeMessageConsumer(consumer); } }
Example #4
Source File: AbstractPollingMessageListenerContainer.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * This implementation checks whether the Session is externally synchronized. * In this case, the Session is not locally transacted, despite the listener * container's "sessionTransacted" flag being set to "true". * @see org.springframework.jms.connection.JmsResourceHolder */ @Override protected boolean isSessionLocallyTransacted(Session session) { if (!super.isSessionLocallyTransacted(session)) { return false; } JmsResourceHolder resourceHolder = (JmsResourceHolder) TransactionSynchronizationManager.getResource(getConnectionFactory()); return (resourceHolder == null || resourceHolder instanceof LocallyExposedJmsResourceHolder || !resourceHolder.containsSession(session)); }
Example #5
Source File: AbstractPollingMessageListenerContainer.java From spring-analysis-note with MIT License | 5 votes |
/** * This implementation checks whether the Session is externally synchronized. * In this case, the Session is not locally transacted, despite the listener * container's "sessionTransacted" flag being set to "true". * @see org.springframework.jms.connection.JmsResourceHolder */ @Override protected boolean isSessionLocallyTransacted(Session session) { if (!super.isSessionLocallyTransacted(session)) { return false; } JmsResourceHolder resourceHolder = (JmsResourceHolder) TransactionSynchronizationManager.getResource(obtainConnectionFactory()); return (resourceHolder == null || resourceHolder instanceof LocallyExposedJmsResourceHolder || !resourceHolder.containsSession(session)); }
Example #6
Source File: JmsTemplate.java From java-technology-stack with MIT License | 4 votes |
@Override @Nullable public Session getSession(JmsResourceHolder holder) { return JmsTemplate.this.getSession(holder); }
Example #7
Source File: JtaUtil.java From iaf with Apache License 2.0 | 4 votes |
public static String displayTransactionStatus(TransactionStatus txStatus) { String result; result="txName ["+TransactionSynchronizationManager.getCurrentTransactionName()+"]"; if (txStatus!=null) { result+=" status new ["+txStatus.isNewTransaction()+"]"; result+=" status completeted ["+txStatus.isCompleted()+"]"; result+=" status rollbackOnly ["+txStatus.isRollbackOnly()+"]"; result+=" status hasSavepoint ["+txStatus.hasSavepoint()+"]"; } else { result+=" currently not in a transaction"; } result+=" isolation ["+TransactionSynchronizationManager.getCurrentTransactionIsolationLevel()+"]"; result+=" active ["+TransactionSynchronizationManager.isActualTransactionActive()+"]"; boolean syncActive=TransactionSynchronizationManager.isSynchronizationActive(); result+=" synchronization active ["+syncActive+"]"; result+="\n"; Map<Object, Object> resources = TransactionSynchronizationManager.getResourceMap(); result += "resources:\n"; if (resources==null) { result+=" map is null\n"; } else { for (Iterator<Object> it=resources.keySet().iterator(); it.hasNext();) { Object key = it.next(); Object resource = resources.get(key); result += ClassUtils.nameOf(key)+"("+key+"): "+ClassUtils.nameOf(resource)+"("+resource+")\n"; if (resource instanceof JmsResourceHolder) { JmsResourceHolder jrh = (JmsResourceHolder)resource; result+=" connection: "+jrh.getConnection()+", session: "+jrh.getSession()+"\n"; } } } if (syncActive) { List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations(); result += "synchronizations:\n"; for (int i=0; i<synchronizations.size(); i++) { TransactionSynchronization synchronization = synchronizations.get(i); result += ClassUtils.nameOf(synchronization)+"("+synchronization+")\n"; } } return result; }
Example #8
Source File: IbisMessageListenerContainer.java From iaf with Apache License 2.0 | 4 votes |
@Override protected Session getSession(JmsResourceHolder holder) { Session session = super.getSession(holder); log.trace("getSession() - ackMode["+getSessionAcknowledgeMode()+"] jmsResourceHolder[" + holder.toString() + "] session["+(session==null?"null":session.toString())+"]"); return session; }
Example #9
Source File: IbisMessageListenerContainer.java From iaf with Apache License 2.0 | 4 votes |
@Override protected Connection getConnection(JmsResourceHolder holder) { Connection conn = super.getConnection(holder); log.trace("getConnection() - jmsResourceHolder[" + holder.toString() + "] connection["+(conn==null?"null":conn.toString())+"]"); return conn; }
Example #10
Source File: BatchedMessageListenerContainer.java From jadira with Apache License 2.0 | 4 votes |
public Session getSession(JmsResourceHolder holder) { return BatchedMessageListenerContainer.this.getSession(holder); }
Example #11
Source File: BatchedMessageListenerContainer.java From jadira with Apache License 2.0 | 4 votes |
public Connection getConnection(JmsResourceHolder holder) { return BatchedMessageListenerContainer.this.getConnection(holder); }
Example #12
Source File: JmsTemplate.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public Session getSession(JmsResourceHolder holder) { return JmsTemplate.this.getSession(holder); }
Example #13
Source File: JmsTemplate.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public Connection getConnection(JmsResourceHolder holder) { return JmsTemplate.this.getConnection(holder); }
Example #14
Source File: AbstractPollingMessageListenerContainer.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public Session getSession(JmsResourceHolder holder) { return AbstractPollingMessageListenerContainer.this.getSession(holder); }
Example #15
Source File: AbstractPollingMessageListenerContainer.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public Connection getConnection(JmsResourceHolder holder) { return AbstractPollingMessageListenerContainer.this.getConnection(holder); }
Example #16
Source File: JmsTemplate.java From java-technology-stack with MIT License | 4 votes |
@Override @Nullable public Connection getConnection(JmsResourceHolder holder) { return JmsTemplate.this.getConnection(holder); }
Example #17
Source File: AbstractPollingMessageListenerContainer.java From java-technology-stack with MIT License | 4 votes |
@Override @Nullable public Session getSession(JmsResourceHolder holder) { return AbstractPollingMessageListenerContainer.this.getSession(holder); }
Example #18
Source File: AbstractPollingMessageListenerContainer.java From spring-analysis-note with MIT License | 4 votes |
@Override @Nullable public Connection getConnection(JmsResourceHolder holder) { return AbstractPollingMessageListenerContainer.this.getConnection(holder); }
Example #19
Source File: AbstractPollingMessageListenerContainer.java From java-technology-stack with MIT License | 4 votes |
@Override @Nullable public Connection getConnection(JmsResourceHolder holder) { return AbstractPollingMessageListenerContainer.this.getConnection(holder); }
Example #20
Source File: AbstractPollingMessageListenerContainer.java From spring-analysis-note with MIT License | 4 votes |
@Override @Nullable public Session getSession(JmsResourceHolder holder) { return AbstractPollingMessageListenerContainer.this.getSession(holder); }
Example #21
Source File: JmsTemplate.java From spring-analysis-note with MIT License | 4 votes |
@Override @Nullable public Connection getConnection(JmsResourceHolder holder) { return JmsTemplate.this.getConnection(holder); }
Example #22
Source File: JmsTemplate.java From spring-analysis-note with MIT License | 4 votes |
@Override @Nullable public Session getSession(JmsResourceHolder holder) { return JmsTemplate.this.getSession(holder); }
Example #23
Source File: JmsTemplate.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Fetch an appropriate Session from the given JmsResourceHolder. * <p>This implementation accepts any JMS 1.1 Session. * @param holder the JmsResourceHolder * @return an appropriate Session fetched from the holder, * or {@code null} if none found */ protected Session getSession(JmsResourceHolder holder) { return holder.getSession(); }
Example #24
Source File: AbstractPollingMessageListenerContainer.java From spring-analysis-note with MIT License | 2 votes |
/** * Fetch an appropriate Connection from the given JmsResourceHolder. * <p>This implementation accepts any JMS 1.1 Connection. * @param holder the JmsResourceHolder * @return an appropriate Connection fetched from the holder, * or {@code null} if none found */ @Nullable protected Connection getConnection(JmsResourceHolder holder) { return holder.getConnection(); }
Example #25
Source File: AbstractPollingMessageListenerContainer.java From spring-analysis-note with MIT License | 2 votes |
/** * Fetch an appropriate Session from the given JmsResourceHolder. * <p>This implementation accepts any JMS 1.1 Session. * @param holder the JmsResourceHolder * @return an appropriate Session fetched from the holder, * or {@code null} if none found */ @Nullable protected Session getSession(JmsResourceHolder holder) { return holder.getSession(); }
Example #26
Source File: JmsTemplate.java From spring-analysis-note with MIT License | 2 votes |
/** * Fetch an appropriate Connection from the given JmsResourceHolder. * <p>This implementation accepts any JMS 1.1 Connection. * @param holder the JmsResourceHolder * @return an appropriate Connection fetched from the holder, * or {@code null} if none found */ @Nullable protected Connection getConnection(JmsResourceHolder holder) { return holder.getConnection(); }
Example #27
Source File: JmsTemplate.java From spring-analysis-note with MIT License | 2 votes |
/** * Fetch an appropriate Session from the given JmsResourceHolder. * <p>This implementation accepts any JMS 1.1 Session. * @param holder the JmsResourceHolder * @return an appropriate Session fetched from the holder, * or {@code null} if none found */ @Nullable protected Session getSession(JmsResourceHolder holder) { return holder.getSession(); }
Example #28
Source File: JmsTemplate.java From java-technology-stack with MIT License | 2 votes |
/** * Fetch an appropriate Session from the given JmsResourceHolder. * <p>This implementation accepts any JMS 1.1 Session. * @param holder the JmsResourceHolder * @return an appropriate Session fetched from the holder, * or {@code null} if none found */ @Nullable protected Session getSession(JmsResourceHolder holder) { return holder.getSession(); }
Example #29
Source File: JmsTemplate.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Fetch an appropriate Connection from the given JmsResourceHolder. * <p>This implementation accepts any JMS 1.1 Connection. * @param holder the JmsResourceHolder * @return an appropriate Connection fetched from the holder, * or {@code null} if none found */ protected Connection getConnection(JmsResourceHolder holder) { return holder.getConnection(); }
Example #30
Source File: AbstractPollingMessageListenerContainer.java From java-technology-stack with MIT License | 2 votes |
/** * Fetch an appropriate Connection from the given JmsResourceHolder. * <p>This implementation accepts any JMS 1.1 Connection. * @param holder the JmsResourceHolder * @return an appropriate Connection fetched from the holder, * or {@code null} if none found */ @Nullable protected Connection getConnection(JmsResourceHolder holder) { return holder.getConnection(); }