Java Code Examples for javax.jms.Session#getAcknowledgeMode()
The following examples show how to use
javax.jms.Session#getAcknowledgeMode() .
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: ClientJmsDelegate.java From qpid-broker-j with Apache License 2.0 | 6 votes |
public int getAcknowledgeMode(final String sessionName) { try { final Session session = _testSessions.get(sessionName); if (session == null) { throw new DistributedTestException("No test session found called: " + sessionName); } return session.getAcknowledgeMode(); } catch (final JMSException jmse) { throw new DistributedTestException("Unable to determine acknowledgement mode for session: " + sessionName, jmse); } }
Example 2
Source File: ClientJmsDelegate.java From qpid-broker-j with Apache License 2.0 | 6 votes |
public void commitOrAcknowledgeMessageIfNecessary(final String sessionName, final Message message) { try { final Session session = _testSessions.get(sessionName); if (session.getTransacted()) { synchronized(session) { session.commit(); } } else if (message != null && session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) { message.acknowledge(); } } catch (final JMSException jmse) { throw new DistributedTestException("Unable to commit or acknowledge message on session: " + sessionName, jmse); } }
Example 3
Source File: ClientJmsDelegate.java From qpid-broker-j with Apache License 2.0 | 6 votes |
public void rollbackOrRecoverIfNecessary(String sessionName) { try { final Session session = _testSessions.get(sessionName); synchronized(session) { if (session.getTransacted()) { session.rollback(); } else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) { session.recover(); } } } catch (final JMSException jmse) { throw new DistributedTestException("Unable to rollback or recover on session: " + sessionName, jmse); } }
Example 4
Source File: JmsClient.java From ats-framework with Apache License 2.0 | 5 votes |
private synchronized Session loadSession( final boolean transacted, final int acknowledgeMode ) throws JMSException { final Session s = session; if (s != null) { if ( (s.getTransacted() == transacted) && (s.getAcknowledgeMode() == acknowledgeMode)) { return s; } s.close(); } final Session newSession = loadConnection().createSession(transacted, acknowledgeMode); session = newSession; return newSession; }
Example 5
Source File: PersistentMessagingTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
private void receiveAndVerifyMessages(final Session session, final MessageConsumer consumer, final List<Message> expectedMessages) throws Exception { for (Message expected : expectedMessages) { final Message received = consumer.receive(getReceiveTimeout()); assertNotNull(String.format("Message not received when expecting message %d", expected.getIntProperty(INT_PROPERTY)), received); assertTrue("Unexpected type", expected instanceof TextMessage); assertEquals("Unexpected index", expected.getIntProperty(INT_PROPERTY), received.getIntProperty(INT_PROPERTY)); assertEquals("Unexpected string property", expected.getStringProperty(STRING_PROPERTY), received.getStringProperty(STRING_PROPERTY)); assertEquals("Unexpected message content", ((TextMessage) expected).getText(), ((TextMessage) received).getText()); final int acknowledgeMode = session.getAcknowledgeMode(); if (acknowledgeMode == SESSION_TRANSACTED) { session.commit(); } else if (acknowledgeMode == CLIENT_ACKNOWLEDGE) { received.acknowledge(); } } }
Example 6
Source File: JMSConsumer.java From nifi with Apache License 2.0 | 4 votes |
private void acknowledge(final Message message, final Session session) throws JMSException { if (message != null && session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) { message.acknowledge(); } }
Example 7
Source File: JmsAccessor.java From spring-analysis-note with MIT License | 2 votes |
/** * Determine whether the given Session is in client acknowledge mode. * <p>This implementation uses JMS 1.1 API. * @param session the JMS Session to check * @return whether the given Session is in client acknowledge mode * @throws javax.jms.JMSException if thrown by JMS API methods * @see javax.jms.Session#getAcknowledgeMode() * @see javax.jms.Session#CLIENT_ACKNOWLEDGE */ protected boolean isClientAcknowledge(Session session) throws JMSException { return (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE); }
Example 8
Source File: JmsAccessor.java From java-technology-stack with MIT License | 2 votes |
/** * Determine whether the given Session is in client acknowledge mode. * <p>This implementation uses JMS 1.1 API. * @param session the JMS Session to check * @return whether the given Session is in client acknowledge mode * @throws javax.jms.JMSException if thrown by JMS API methods * @see javax.jms.Session#getAcknowledgeMode() * @see javax.jms.Session#CLIENT_ACKNOWLEDGE */ protected boolean isClientAcknowledge(Session session) throws JMSException { return (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE); }
Example 9
Source File: JmsAccessor.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Determine whether the given Session is in client acknowledge mode. * <p>This implementation uses JMS 1.1 API. * @param session the JMS Session to check * @return whether the given Session is in client acknowledge mode * @throws javax.jms.JMSException if thrown by JMS API methods * @see javax.jms.Session#getAcknowledgeMode() * @see javax.jms.Session#CLIENT_ACKNOWLEDGE */ protected boolean isClientAcknowledge(Session session) throws JMSException { return (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE); }