Example usage for org.springframework.jms.core JmsTemplate setPubSubDomain

List of usage examples for org.springframework.jms.core JmsTemplate setPubSubDomain

Introduction

In this page you can find the example usage for org.springframework.jms.core JmsTemplate setPubSubDomain.

Prototype

public void setPubSubDomain(boolean pubSubDomain) 

Source Link

Document

Configure the destination accessor with knowledge of the JMS domain used.

Usage

From source file:biz.fstechnology.micro.common.jms.JmsServiceConnection.java

public static JmsServiceConnection getInstance(String defaultDestination, ConnectionFactory connectionFactory) {
    if (INSTANCE.getJmsTemplate() != null) {
        // WARNING: the instance may be initialized. this cause
        // re-initialize and previous settings are lost.
    }//from w ww. j  a v a 2  s  .  co  m
    JmsTemplate template = new JmsTemplate(connectionFactory);
    template.setPubSubDomain(true);
    INSTANCE.setJmsTemplate(template);
    INSTANCE.setDefaultDestination(defaultDestination);
    return INSTANCE;
}

From source file:com.create.application.configuration.JmsConfiguration.java

@Bean
public JmsTemplate jmsTemplate(final ConnectionFactory connectionFactory, final JmsProperties properties,
        final Destination destination) {
    final JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    jmsTemplate.setPubSubDomain(properties.isPubSubDomain());
    jmsTemplate.setDefaultDestination(destination);
    if (destinationResolver != null) {
        jmsTemplate.setDestinationResolver(destinationResolver);
    }/*w  w w. j  a va2  s  .  c o  m*/
    return jmsTemplate;
}

From source file:com.kinglcc.spring.jms.config.JmsAnnotationAtuoConfiguration.java

@Bean
@ConditionalOnMissingBean//from  ww  w . j a va  2  s  . c o  m
public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory) {
    JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    jmsTemplate.setPubSubDomain(this.properties.isPubSubDomain());
    if (this.destinationResolver != null) {
        jmsTemplate.setDestinationResolver(this.destinationResolver);
    }
    jmsTemplate.setMessageConverter(messageConverter);
    return jmsTemplate;
}

From source file:biz.fstechnology.micro.server.jms.AbstractJmsService.java

protected final JmsTemplate createJmsTemplate() {
    JmsTemplate jmsTemplate = new JmsTemplate(getConnectionFactory());
    jmsTemplate.setPubSubDomain(true);
    return jmsTemplate;
}

From source file:edu.berkeley.path.next.CTMEngine.JmsConfiguration.java

@Bean
public JmsTemplate jmsTemplate() {
    JmsTemplate jmsTemplate = new JmsTemplate();
    jmsTemplate.setConnectionFactory(connectionFactory());
    jmsTemplate.setDefaultDestinationName("notification");
    jmsTemplate.setPubSubDomain(true);
    return jmsTemplate;
}

From source file:com.jim.im.config.GenericMQConfig.java

@Bean
public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory, JmsProperties properties,
        MessageConverter messageConverter, DestinationResolver destinationResolver) {
    JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    jmsTemplate.setMessageConverter(messageConverter);
    jmsTemplate.setPubSubDomain(properties.isPubSubDomain());
    jmsTemplate.setDeliveryMode(Session.AUTO_ACKNOWLEDGE);
    if (destinationResolver != null) {
        jmsTemplate.setDestinationResolver(destinationResolver);
    }/*from  w  w  w .j  a va 2  s  .  co m*/
    jmsTemplate.setDefaultDestinationName(IMConstant.MQ_FORWARD_TOPIC_NAME);
    return jmsTemplate;
}

From source file:org.apache.servicemix.jms.JmsConsumerEndpointTest.java

public void testDurableConsumerDefault() throws Exception {
    JmsComponent component = new JmsComponent();
    JmsConsumerEndpoint endpoint = new JmsConsumerEndpoint();
    endpoint.setService(new QName("jms"));
    endpoint.setEndpoint("endpoint");
    endpoint.setTargetService(new QName("receiver"));
    endpoint.setListenerType("default");
    endpoint.setConnectionFactory(connectionFactory);
    endpoint.setPubSubDomain(true);//from  ww  w.  j a  va2  s .  co m
    endpoint.setSubscriptionDurable(true);
    endpoint.setClientId("clientId");
    endpoint.setDestinationName("destinationTopic");
    endpoint.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONNECTION);
    component.setEndpoints(new JmsConsumerEndpoint[] { endpoint });
    container.activateComponent(component, "servicemix-jms");
    Thread.sleep(500);
    container.start();

    JmsTemplate jmsTemplate = new JmsTemplate();
    jmsTemplate.setConnectionFactory(new PooledConnectionFactory(connectionFactory));
    jmsTemplate.setPubSubDomain(true);
    jmsTemplate.afterPropertiesSet();
    jmsTemplate.convertAndSend("destinationTopic", "<hello>world</hello>");
    receiver.getMessageList().assertMessagesReceived(1);
    Thread.sleep(500);
}

From source file:com.ruyicai.msgcenter.jms.WithoutTMJmsConfiguration.java

/**
 * Creates a {@link JmsOperations} object used for one way messaging
 *//*from   w ww .j  ava2  s .co  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.servicemix.jms.endpoints.JmsProviderEndpoint.java

/**
 * Create the JMS template to be used to send the JMS messages.
 *
 * @return/*  ww  w  . ja  va 2 s .  c  o  m*/
 */
protected JmsTemplate createTemplate() {
    JmsTemplate tplt;
    if (isJms102()) {
        tplt = new JmsTemplate102();
    } else {
        tplt = new JmsTemplate();
    }
    tplt.setConnectionFactory(getConnectionFactory());
    if (getDestination() != null) {
        tplt.setDefaultDestination(getDestination());
    } else if (getDestinationName() != null) {
        tplt.setDefaultDestinationName(getDestinationName());
    }
    tplt.setDeliveryMode(getDeliveryMode());
    if (getDestinationResolver() != null) {
        tplt.setDestinationResolver(getDestinationResolver());
    }
    tplt.setExplicitQosEnabled(isExplicitQosEnabled());
    tplt.setMessageIdEnabled(isMessageIdEnabled());
    tplt.setMessageTimestampEnabled(isMessageTimestampEnabled());
    tplt.setPriority(getPriority());
    tplt.setPubSubDomain(isPubSubDomain());
    tplt.setPubSubNoLocal(isPubSubNoLocal());
    tplt.setTimeToLive(getTimeToLive());
    tplt.setReceiveTimeout(getReceiveTimeout());
    tplt.afterPropertiesSet();
    return tplt;
}

From source file:org.apache.camel.component.jms.JmsConfiguration.java

/**
 * Creates a {@link JmsOperations} object used for one way messaging
 *//*from  w  ww  .  j a v  a 2 s  . c  om*/
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;
}