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

The following examples show how to use org.springframework.jms.core.JmsTemplate#setDeliveryPersistent() . 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: JndiProducerConfiguration.java    From solace-jms-spring-boot with Apache License 2.0 5 votes vote down vote up
@Bean
public JmsTemplate producerJmsTemplate() {
	JmsTemplate jt = new JmsTemplate(producerCachingConnectionFactory());
	jt.setDeliveryPersistent(true);
	jt.setDestinationResolver(producerJndiDestinationResolver());
	return jt;
}
 
Example 2
Source File: JndiProducerConfiguration.java    From solace-samples-cloudfoundry-java with Apache License 2.0 5 votes vote down vote up
@Bean
public JmsTemplate producerJmsTemplate() {
	JmsTemplate jt = new JmsTemplate(cachingConnectionFactory());
	jt.setDeliveryPersistent(true);
	jt.setDestinationResolver(producerJndiDestinationResolver());
	jt.setPubSubDomain(true);	// This sample is publishing to topics
	return jt;
}
 
Example 3
Source File: JmsConfig.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public JmsTemplate clientJmsTemplate() {
  JmsTemplate jmsTemplate = new JmsTemplate(new CachingConnectionFactory(clientJmsConnectionFactory()));
  jmsTemplate.setExplicitQosEnabled(true);
  jmsTemplate.setDeliveryPersistent(false);
  return jmsTemplate;
}
 
Example 4
Source File: JmsTopicTemplateFactory.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new {@link JmsTemplate} with standardized configuration 
 * @param connectionFactory The JMS connection factory
 * @param clientTopicMsgTimeToLive Time-to-live in seconds
 * @return A new {@link JmsTemplate} instance with standardized configuration
 */
static JmsTemplate createJmsTemplate(ConnectionFactory connectionFactory, int clientTopicMsgTimeToLive) {
  JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);

  jmsTemplate.setExplicitQosEnabled(true);
  
  // message time-to-live in ms
  long ttl = clientTopicMsgTimeToLive * 1000L;
  jmsTemplate.setTimeToLive(ttl);
  
  jmsTemplate.setDeliveryPersistent(false);
  jmsTemplate.setSessionTransacted(false);
  
  return jmsTemplate;
}
 
Example 5
Source File: JmsConfig.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addDefaultProcessRequestJmsTemplateProperties(JmsTemplate jmsTemplate) {
  String queueTrunk = properties.getJms().getQueuePrefix();
  jmsTemplate.setDefaultDestination(new ActiveMQQueue(queueTrunk + ".request"));
  jmsTemplate.setExplicitQosEnabled(true);
  // timeToLive the message's lifetime (in milliseconds)
  long ttl = properties.getJms().getRequestMsgtimeToLive() * 1000L;
  jmsTemplate.setTimeToLive(ttl);
  jmsTemplate.setDeliveryPersistent(false);
}
 
Example 6
Source File: SensorPublisher.java    From oneops with Apache License 2.0 4 votes vote down vote up
/**
 * Inits the.
 *
 * @throws JMSException the jMS exception
 */
public void init() throws JMSException {
    Properties properties = new Properties();
    try {
        properties.load(this.getClass().getResourceAsStream("/sink.properties"));
    } catch (IOException e) {
        logger.error("got: " + e.getMessage());
    }

    user = properties.getProperty("amq.user");
    password = System.getenv("KLOOPZ_AMQ_PASS");


    if (password == null) {
        throw new JMSException("missing KLOOPZ_AMQ_PASS env var");
    }

    AMQConnectorURI connectStringGenerator = new AMQConnectorURI();
    connectStringGenerator.setHost("opsmq");
    connectStringGenerator.setProtocol("tcp");
    connectStringGenerator.setPort(61616);
    connectStringGenerator.setTransport("failover");
    connectStringGenerator.setDnsResolve(true);
    connectStringGenerator.setKeepAlive(true);
    HashMap<String, String> transportOptions = new HashMap<>();
    transportOptions.put("initialReconnectDelay", "1000");
    transportOptions.put("startupMaxReconnectAttempts", mqConnectionStartupRetries);
    transportOptions.put("timeout", mqConnectionTimeout);
    transportOptions.put("useExponentialBackOff", "false");
    connectStringGenerator.setTransportOptions(transportOptions);
    url = connectStringGenerator.build();

    showParameters();

    // Create the connection.
    ActiveMQConnectionFactory amqConnectionFactory = new ActiveMQConnectionFactory(user, password, url);
    amqConnectionFactory.setUseAsyncSend(true);
    PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(amqConnectionFactory);
    pooledConnectionFactory.setMaxConnections(amqConnectionPoolSize);
    pooledConnectionFactory.setIdleTimeout(10000);

    for (int i = 0; i < poolsize; i++) {
        JmsTemplate producerTemplate = new JmsTemplate(pooledConnectionFactory);
        producerTemplate.setSessionTransacted(false);
        int shard = i + 1;
        Destination perfin = new org.apache.activemq.command.ActiveMQQueue(queueBase + "-" + shard);
        producerTemplate.setDefaultDestination(perfin);
        producerTemplate.setDeliveryPersistent(false);
        producers[i] = producerTemplate;
    }


}