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

The following examples show how to use org.springframework.jms.core.JmsTemplate#setDefaultDestination() . 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: SenderConfig.java    From spring-jms with MIT License 5 votes vote down vote up
@Bean
public JmsTemplate orderJmsTemplate() {
  JmsTemplate jmsTemplate =
      new JmsTemplate(cachingConnectionFactory());
  jmsTemplate.setDefaultDestination(orderDestination());
  jmsTemplate.setReceiveTimeout(5000);

  return jmsTemplate;
}
 
Example 2
Source File: SupervisionJmsConfig.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public JmsTemplate supervisionTopicPublisherJmsTemplate() {
  int ttl = properties.getJms().getClientTopicMsgTimeToLive();
  JmsTemplate jmsTemplate = JmsTopicTemplateFactory.createJmsTemplate(clientSingleConnectionFactory, ttl);
  String supervisionTopic = properties.getJms().getSupervisionTopic();
  jmsTemplate.setDefaultDestination(new ActiveMQTopic(supervisionTopic));
  return jmsTemplate;
}
 
Example 3
Source File: AlarmJmsConfig.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public JmsTemplate alarmTopicPublisherJmsTemplate() {
  int ttl = properties.getJms().getClientTopicMsgTimeToLive();
  JmsTemplate jmsTemplate = JmsTopicTemplateFactory.createJmsTemplate(clientSingleConnectionFactory, ttl);

  String alarmTopic = properties.getJms().getAlarmTopic();
  jmsTemplate.setDefaultDestination(new ActiveMQTopic(alarmTopic));

  return jmsTemplate;
}
 
Example 4
Source File: HeartbeatJmsConfig.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public JmsTemplate heartbeatJmsTemplate() {
  int ttl = properties.getJms().getClientTopicMsgTimeToLive();
  JmsTemplate jmsTemplate = JmsTopicTemplateFactory.createJmsTemplate(heartbeatSingleConnectionFactory(), ttl);
  jmsTemplate.setDefaultDestination(new ActiveMQTopic(properties.getJms().getHeartbeatTopic()));
  jmsTemplate.setPriority(7);
  return jmsTemplate;
}
 
Example 5
Source File: JmsUpdateQueueTemplateFactory.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Note, that the {@link JmsTemplate#setQosSettings(QosSettings)} is implicitly calling 
 * {@link JmsTemplate#setExplicitQosEnabled(boolean)}
 * @param settings the Quality of Service settings for the template 
 */
private void createDataTagValueUpdateJmsTemplate(QosSettings settings) {
  JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
  jmsTemplate.setDefaultDestination(destination);
  jmsTemplate.setQosSettings(settings);
  jmsTemplate.setMessageConverter(new DataTagValueUpdateConverter());
  jmsTemplateMap.put(settings, jmsTemplate);
}
 
Example 6
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 7
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;
    }


}