List of usage examples for org.springframework.jms.core JmsTemplate setSessionTransacted
public void setSessionTransacted(boolean sessionTransacted)
From source file:org.springsource.jta.etailer.store.config.MessagingConfiguration.java
@Bean public JmsTemplate jmsTemplate() throws Throwable { JmsTemplate jmsTemplate = new JmsTemplate(jtaConfiguration.connectionFactory()); jmsTemplate.setSessionTransacted(true); return jmsTemplate; }
From source file:com.springsource.open.jms.SharedDatabaseApplication.java
@Bean public BeanPostProcessor jmsPostProcessor() { return new BeanPostProcessor() { @Override/*from w ww . j a v a 2 s . c om*/ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { return bean; } @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof JmsTemplate) { JmsTemplate template = (JmsTemplate) bean; template.setReceiveTimeout(200L); template.setSessionTransacted(true); } return bean; } }; }
From source file:ragna.wl1036.web.support.infra.ComponentConfig.java
@Bean public JmsTemplate jmsSenderTemplate() { JmsTemplate jmsTemplate = new JmsTemplate((ConnectionFactory) jmsConnectionFactory().getObject()); jmsTemplate.setSessionTransacted(false); jmsTemplate.setReceiveTimeout(5000); jmsTemplate.setDefaultDestination((Destination) jmsQueueName().getObject()); return jmsTemplate; }
From source file:org.springsource.greenbeans.examples.edawithspring.etailer.store.StoreConfiguration.java
@Bean public JmsTemplate jmsTemplate() { JmsTemplate jmsTemplate = new JmsTemplate(this.connectionFactory()); jmsTemplate.setSessionTransacted(true); return jmsTemplate; }
From source file:com.oneops.daq.jms.SensorPublisher.java
/** * Inits the.//from www. j a va 2s. c o m * * @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(4); 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; } }
From source file:com.ruyicai.msgcenter.jms.WithoutTMJmsConfiguration.java
/** * Creates a {@link JmsOperations} object used for request/response using a request timeout value *///from ww w . java 2 s . c o m public JmsOperations createInOutTemplate(JmsEndpoint endpoint, boolean pubSubDomain, String destination, long requestTimeout) { JmsOperations answer = createInOnlyTemplate(endpoint, pubSubDomain, destination); if (answer instanceof JmsTemplate && requestTimeout > 0) { JmsTemplate jmsTemplate = (JmsTemplate) answer; jmsTemplate.setExplicitQosEnabled(true); // prefer to use timeToLive over requestTimeout if both specified long ttl = timeToLive > 0 ? timeToLive : requestTimeout; if (ttl > 0 && !isDisableTimeToLive()) { // only use TTL if not disabled jmsTemplate.setTimeToLive(ttl); } jmsTemplate.setSessionTransacted(isTransactedInOut()); if (isTransactedInOut()) { jmsTemplate.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED); } else { if (acknowledgementMode >= 0) { jmsTemplate.setSessionAcknowledgeMode(acknowledgementMode); } else if (acknowledgementModeName != null) { jmsTemplate.setSessionAcknowledgeModeName(acknowledgementModeName); } else { // default to AUTO jmsTemplate.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE); } } } return answer; }
From source file:com.ruyicai.msgcenter.jms.WithoutTMJmsConfiguration.java
/** * Creates a {@link JmsOperations} object used for one way messaging *//* ww w . java 2s . c o m*/ public JmsOperations createInOnlyTemplate(JmsEndpoint endpoint, boolean pubSubDomain, String destination) { if (jmsOperations != null) { return jmsOperations; } ConnectionFactory factory = getTemplateConnectionFactory(); JmsTemplate template = new CamelJmsTemplate(this, factory); template.setPubSubDomain(pubSubDomain); if (destinationResolver != null) { template.setDestinationResolver(destinationResolver); if (endpoint instanceof DestinationEndpoint) { LOG.debug( "You are overloading the destinationResolver property on a DestinationEndpoint; are you sure you want to do that?"); } } else if (endpoint instanceof DestinationEndpoint) { DestinationEndpoint destinationEndpoint = (DestinationEndpoint) endpoint; template.setDestinationResolver(createDestinationResolver(destinationEndpoint)); } template.setDefaultDestinationName(destination); template.setExplicitQosEnabled(isExplicitQosEnabled()); template.setDeliveryPersistent(deliveryPersistent); if (messageConverter != null) { template.setMessageConverter(messageConverter); } template.setMessageIdEnabled(messageIdEnabled); template.setMessageTimestampEnabled(messageTimestampEnabled); if (priority >= 0) { template.setPriority(priority); } template.setPubSubNoLocal(pubSubNoLocal); if (receiveTimeout >= 0) { template.setReceiveTimeout(receiveTimeout); } // only set TTL if we have a positive value and it has not been disabled if (timeToLive >= 0 && !isDisableTimeToLive()) { template.setTimeToLive(timeToLive); } template.setSessionTransacted(transacted); if (transacted) { template.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED); } else { // This is here for completeness, but the template should not get // used for receiving messages. if (acknowledgementMode >= 0) { template.setSessionAcknowledgeMode(acknowledgementMode); } else if (acknowledgementModeName != null) { template.setSessionAcknowledgeModeName(acknowledgementModeName); } } return template; }
From source file:org.apache.camel.component.jms.JmsConfiguration.java
/** * Creates a {@link JmsOperations} object used for request/response using a request timeout value *///w w w. ja va 2s .c o m public JmsOperations createInOutTemplate(JmsEndpoint endpoint, boolean pubSubDomain, String destination, long requestTimeout) { JmsOperations answer = createInOnlyTemplate(endpoint, pubSubDomain, destination); if (answer instanceof JmsTemplate && requestTimeout > 0) { JmsTemplate jmsTemplate = (JmsTemplate) answer; jmsTemplate.setExplicitQosEnabled(true); if (timeToLive < 0) { // If TTL not specified, then default to jmsTemplate.setTimeToLive(requestTimeout); } jmsTemplate.setSessionTransacted(isTransactedInOut()); if (isTransactedInOut()) { jmsTemplate.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED); } else { if (acknowledgementMode >= 0) { jmsTemplate.setSessionAcknowledgeMode(acknowledgementMode); } else if (acknowledgementModeName != null) { jmsTemplate.setSessionAcknowledgeModeName(acknowledgementModeName); } else { // default to AUTO jmsTemplate.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE); } } } return answer; }
From source file:org.apache.camel.component.jms.JmsConfiguration.java
/** * Creates a {@link JmsOperations} object used for one way messaging *//* w w w . ja v a2s . c o m*/ public JmsOperations createInOnlyTemplate(JmsEndpoint endpoint, boolean pubSubDomain, String destination) { if (jmsOperations != null) { return jmsOperations; } ConnectionFactory factory = getTemplateConnectionFactory(); JmsTemplate template = new CamelJmsTemplate(this, factory); template.setPubSubDomain(pubSubDomain); if (destinationResolver != null) { template.setDestinationResolver(destinationResolver); if (endpoint instanceof DestinationEndpoint) { LOG.debug( "You are overloading the destinationResolver property on a DestinationEndpoint; are you sure you want to do that?"); } } else if (endpoint instanceof DestinationEndpoint) { DestinationEndpoint destinationEndpoint = (DestinationEndpoint) endpoint; template.setDestinationResolver(createDestinationResolver(destinationEndpoint)); } template.setDefaultDestinationName(destination); template.setExplicitQosEnabled(isExplicitQosEnabled()); template.setDeliveryPersistent(deliveryPersistent); if (messageConverter != null) { template.setMessageConverter(messageConverter); } template.setMessageIdEnabled(messageIdEnabled); template.setMessageTimestampEnabled(messageTimestampEnabled); if (priority >= 0) { template.setPriority(priority); } template.setPubSubNoLocal(pubSubNoLocal); if (receiveTimeout >= 0) { template.setReceiveTimeout(receiveTimeout); } if (timeToLive >= 0) { template.setTimeToLive(timeToLive); } template.setSessionTransacted(transacted); if (transacted) { template.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED); } else { // This is here for completeness, but the template should not get // used for receiving messages. if (acknowledgementMode >= 0) { template.setSessionAcknowledgeMode(acknowledgementMode); } else if (acknowledgementModeName != null) { template.setSessionAcknowledgeModeName(acknowledgementModeName); } } return template; }