Java Code Examples for org.springframework.jms.core.JmsTemplate#setSessionAcknowledgeMode()

The following examples show how to use org.springframework.jms.core.JmsTemplate#setSessionAcknowledgeMode() . 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: ConsumeJMSManualTest.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void send(MessageCreator messageCreator) throws Exception {
    final String  destinationName = "TEST";

    ConnectionFactory activeMqConnectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
    final ConnectionFactory connectionFactory = new CachingConnectionFactory(activeMqConnectionFactory);

    JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    jmsTemplate.setPubSubDomain(false);
    jmsTemplate.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
    jmsTemplate.setReceiveTimeout(10L);

    try {
        JMSPublisher sender = new JMSPublisher((CachingConnectionFactory) jmsTemplate.getConnectionFactory(), jmsTemplate, mock(ComponentLog.class));

        sender.jmsTemplate.send(destinationName, messageCreator);
    } finally {
        ((CachingConnectionFactory) jmsTemplate.getConnectionFactory()).destroy();
    }
}
 
Example 2
Source File: ConsumeJMS.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Will create an instance of {@link JMSConsumer}
 */
@Override
protected JMSConsumer finishBuildingTargetResource(JmsTemplate jmsTemplate, ProcessContext processContext) {
    int ackMode = processContext.getProperty(ACKNOWLEDGEMENT_MODE).asInteger();
    jmsTemplate.setSessionAcknowledgeMode(ackMode);
    return new JMSConsumer(jmsTemplate, this.getLogger());
}
 
Example 3
Source File: ConsumeJMS.java    From solace-integration-guides with Apache License 2.0 5 votes vote down vote up
/**
 * Will create an instance of {@link JMSConsumer}
 */
@Override
protected JMSConsumer finishBuildingTargetResource(JmsTemplate jmsTemplate, ProcessContext processContext) {
    int ackMode = processContext.getProperty(ACKNOWLEDGEMENT_MODE).asInteger();
    jmsTemplate.setSessionAcknowledgeMode(ackMode);
    return new JMSConsumer(jmsTemplate, this.getLogger());
}
 
Example 4
Source File: ConsumeJMS.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Will create an instance of {@link JMSConsumer}
 */
@Override
protected JMSConsumer finishBuildingJmsWorker(CachingConnectionFactory connectionFactory, JmsTemplate jmsTemplate, ProcessContext processContext) {
    int ackMode = processContext.getProperty(ACKNOWLEDGEMENT_MODE).asInteger();
    jmsTemplate.setSessionAcknowledgeMode(ackMode);

    long timeout = processContext.getProperty(TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS);
    jmsTemplate.setReceiveTimeout(timeout);

    return new JMSConsumer(connectionFactory, jmsTemplate, this.getLogger());
}
 
Example 5
Source File: CommonTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
static JmsTemplate buildJmsTemplateForDestination(boolean pubSub) {
    ConnectionFactory activeMqConnectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
    final ConnectionFactory connectionFactory = new CachingConnectionFactory(activeMqConnectionFactory);

    JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    jmsTemplate.setPubSubDomain(pubSub);
    jmsTemplate.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
    jmsTemplate.setReceiveTimeout(10L);
    return jmsTemplate;
}