Java Code Examples for javax.jms.JMSContext#DUPS_OK_ACKNOWLEDGE

The following examples show how to use javax.jms.JMSContext#DUPS_OK_ACKNOWLEDGE . 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: JmsConnector.java    From smallrye-reactive-messaging with Apache License 2.0 7 votes vote down vote up
private JMSContext createContext(ConnectionFactory factory, String username, String password, String mode) {
    int sessionMode;
    switch (mode.toUpperCase()) {
        case "AUTO_ACKNOWLEDGE":
            sessionMode = JMSContext.AUTO_ACKNOWLEDGE;
            break;
        case "SESSION_TRANSACTED":
            sessionMode = JMSContext.SESSION_TRANSACTED;
            break;
        case "CLIENT_ACKNOWLEDGE":
            sessionMode = JMSContext.CLIENT_ACKNOWLEDGE;
            break;
        case "DUPS_OK_ACKNOWLEDGE":
            sessionMode = JMSContext.DUPS_OK_ACKNOWLEDGE;
            break;
        default:
            throw ex.illegalStateUnknowSessionMode(mode);
    }

    if (username != null) {
        return factory.createContext(username, password, sessionMode);
    } else {
        return factory.createContext(sessionMode);
    }
}
 
Example 2
Source File: JmsContextTest.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Test
public void testAcknowledgeNoopDupsOkAcknowledge() throws JMSException {
    JmsConnection connection = Mockito.mock(JmsConnection.class);
    JmsSession session = Mockito.mock(JmsSession.class);

    Mockito.when(connection.createSession(Mockito.anyInt())).thenReturn(session);

    JmsContext context = new JmsContext(connection, JMSContext.DUPS_OK_ACKNOWLEDGE);

    try {
        context.acknowledge();
    } finally {
        context.close();
    }

    Mockito.verify(session, Mockito.times(0)).acknowledge(ACK_TYPE.ACCEPTED);
}
 
Example 3
Source File: JmsPoolJMSContext.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
private void validateSessionMode(int mode) {
    switch (mode) {
        case JMSContext.SESSION_TRANSACTED:
        case JMSContext.AUTO_ACKNOWLEDGE:
        case JMSContext.CLIENT_ACKNOWLEDGE:
        case JMSContext.DUPS_OK_ACKNOWLEDGE:
            return;
        default:
            throw new JMSRuntimeException("Invalid Session Mode: " + mode);
    }
}
 
Example 4
Source File: MockJMSSession.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
static void validateSessionMode(int mode) {
    switch (mode) {
        case JMSContext.AUTO_ACKNOWLEDGE:
        case JMSContext.CLIENT_ACKNOWLEDGE:
        case JMSContext.DUPS_OK_ACKNOWLEDGE:
        case JMSContext.SESSION_TRANSACTED:
            return;
        default:
            throw new JMSRuntimeException("Invalid Session Mode: " + mode);
    }
}
 
Example 5
Source File: ActiveMQConnectionFactory.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private static void validateSessionMode(int mode) {
   switch (mode) {
      case JMSContext.AUTO_ACKNOWLEDGE:
      case JMSContext.CLIENT_ACKNOWLEDGE:
      case JMSContext.DUPS_OK_ACKNOWLEDGE:
      case JMSContext.SESSION_TRANSACTED:
      case ActiveMQJMSConstants.PRE_ACKNOWLEDGE:
      case ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE: {
         return;
      }
      default:
         throw new JMSRuntimeException("Invalid Session Mode: " + mode);
   }
}
 
Example 6
Source File: JmsSession.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
static void validateSessionMode(int mode) {
    switch (mode) {
        case JMSContext.AUTO_ACKNOWLEDGE:
        case JMSContext.CLIENT_ACKNOWLEDGE:
        case JMSContext.DUPS_OK_ACKNOWLEDGE:
        case JMSContext.SESSION_TRANSACTED:
        case INDIVIDUAL_ACKNOWLEDGE:
        case ARTEMIS_PRE_ACKNOWLEDGE:
        case NO_ACKNOWLEDGE:
            return;
        default:
            throw new JMSRuntimeException("Invalid Session Mode: " + mode);
    }
}
 
Example 7
Source File: JMSConsumerIntegrationTest.java    From qpid-jms with Apache License 2.0 4 votes vote down vote up
public void doTestReceiveBodyFailsThenCalledWithCorrectType(int sessionMode) throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
        JMSContext context = testFixture.createJMSContext(testPeer);

        testPeer.expectBegin();

        final String content = "Message-Content";
        Queue queue = context.createQueue("myQueue");

        DescribedType amqpValueContent = new AmqpValueDescribedType(content);

        testPeer.expectReceiverAttach();
        testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueContent);

        JMSConsumer messageConsumer = context.createConsumer(queue);
        try {
            messageConsumer.receiveBody(Boolean.class, 3000);
            fail("Should not read as Boolean type");
        } catch (MessageFormatRuntimeException mfre) {
        }

        testPeer.waitForAllHandlersToComplete(3000);

        if (sessionMode == JMSContext.AUTO_ACKNOWLEDGE ||
            sessionMode == JMSContext.DUPS_OK_ACKNOWLEDGE) {

            testPeer.expectDispositionThatIsAcceptedAndSettled();
        }

        String received = messageConsumer.receiveBody(String.class, 3000);

        if (sessionMode == JMSContext.AUTO_ACKNOWLEDGE ||
            sessionMode == JMSContext.DUPS_OK_ACKNOWLEDGE) {

            assertNotNull(received);
            assertEquals(content, received);
        } else {
            assertNull(received);
        }

        testPeer.expectEnd();
        testPeer.expectClose();

        context.close();

        testPeer.waitForAllHandlersToComplete(3000);
    }
}