Java Code Examples for org.springframework.jms.connection.SingleConnectionFactory

The following examples show how to use org.springframework.jms.connection.SingleConnectionFactory. These examples are extracted from open source projects. 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
@Override
public Connection createConnection() throws JMSException {
	if (AbstractPollingMessageListenerContainer.this.sharedConnectionEnabled()) {
		Connection sharedCon = AbstractPollingMessageListenerContainer.this.getSharedConnection();
		return new SingleConnectionFactory(sharedCon).createConnection();
	}
	else {
		return AbstractPollingMessageListenerContainer.this.createConnection();
	}
}
 
Example 2
@Override
public Connection createConnection() throws JMSException {
	if (AbstractPollingMessageListenerContainer.this.sharedConnectionEnabled()) {
		Connection sharedCon = AbstractPollingMessageListenerContainer.this.getSharedConnection();
		return new SingleConnectionFactory(sharedCon).createConnection();
	}
	else {
		return AbstractPollingMessageListenerContainer.this.createConnection();
	}
}
 
Example 3
@Override
public Connection createConnection() throws JMSException {
	if (AbstractPollingMessageListenerContainer.this.sharedConnectionEnabled()) {
		Connection sharedCon = AbstractPollingMessageListenerContainer.this.getSharedConnection();
		return new SingleConnectionFactory(sharedCon).createConnection();
	}
	else {
		return AbstractPollingMessageListenerContainer.this.createConnection();
	}
}
 
Example 4
Source Project: roncoo-pay   Source File: ActiveMqListenerConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 消息监听容器
 *
 * @param singleConnectionFactory             连接工厂
 * @param tradeQueueDestination               消息目的地
 * @param consumerSessionAwareMessageListener 监听器实现
 * @return 消息监听容器
 */
@Bean(name = "tradeQueueMessageListenerContainer")
public DefaultMessageListenerContainer tradeQueueMessageListenerContainer(@Qualifier("connectionFactory") SingleConnectionFactory singleConnectionFactory, @Qualifier("tradeQueueDestination") ActiveMQQueue tradeQueueDestination, @Qualifier("consumerSessionAwareMessageListener") ConsumerSessionAwareMessageListener consumerSessionAwareMessageListener) {
    DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer();
    messageListenerContainer.setConnectionFactory(singleConnectionFactory);
    messageListenerContainer.setMessageListener(consumerSessionAwareMessageListener);
    messageListenerContainer.setDestination(tradeQueueDestination);
    return messageListenerContainer;
}
 
Example 5
Source Project: roncoo-pay   Source File: ActiveMqListenerConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 消息监听容器
 *
 * @param singleConnectionFactory    连接工厂
 * @param orderQueryQueueDestination 消息目的地
 * @param pollingMessageListener     监听器实现
 * @return 消息监听容器
 */
@Bean(name = "orderQueryQueueMessageListenerContainer")
public DefaultMessageListenerContainer orderQueryQueueMessageListenerContainer(@Qualifier("connectionFactory") SingleConnectionFactory singleConnectionFactory, @Qualifier("orderQueryQueueDestination") ActiveMQQueue orderQueryQueueDestination, @Qualifier("pollingMessageListener") PollingMessageListener pollingMessageListener) {
    DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer();
    messageListenerContainer.setConnectionFactory(singleConnectionFactory);
    messageListenerContainer.setDestination(orderQueryQueueDestination);
    messageListenerContainer.setMessageListener(pollingMessageListener);
    return messageListenerContainer;
}
 
Example 6
Source Project: roncoo-pay   Source File: ActiveMqConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 队列模板
 *
 * @param singleConnectionFactory 连接工厂
 * @return 队列模板
 */
@Bean(name = "jmsTemplate")
public JmsTemplate jmsTemplate(@Qualifier("connectionFactory") SingleConnectionFactory singleConnectionFactory) {
    JmsTemplate notifyJmsTemplate = new JmsTemplate();
    notifyJmsTemplate.setConnectionFactory(singleConnectionFactory);
    notifyJmsTemplate.setDefaultDestinationName(orderQueryDestinationName);
    return notifyJmsTemplate;
}
 
Example 7
/**
 * Constructor.
 * @param clientJmsContainer JMS container used in client module
 * @param clientExecutor thread pool used by container
 * @param singleConnectionFactory client request connection factory
 *
 */
@Autowired
public ClientModuleLifecycle(@Qualifier("clientRequestJmsContainer") final DefaultMessageListenerContainer clientJmsContainer,
                                  @Qualifier("clientExecutor") final ThreadPoolExecutor clientExecutor,
                                  @Qualifier("clientSingleConnectionFactory") final SingleConnectionFactory singleConnectionFactory,
                                  @Qualifier("adminRequestJmsContainer") final DefaultMessageListenerContainer adminJmsContainer,
                                  @Qualifier("adminSingleConnectionFactory") final SingleConnectionFactory adminSingleConnectionFactory) {
  super();
  this.clientJmsContainer = clientJmsContainer;
  this.clientExecutor = clientExecutor;
  this.singleConnectionFactory = singleConnectionFactory;
  this.adminConnectionFactory = adminSingleConnectionFactory;
  this.adminJmsContainer = adminJmsContainer;
}
 
Example 8
@Override
public void stop() {
  if (running) {
    running = false;
    try {
      LOGGER.debug("Shutting down ProcessCommunicationManager bean and associated JMS connections.");
      if (processOutConnectionFactory instanceof SingleConnectionFactory) {
        ((SingleConnectionFactory) processOutConnectionFactory).destroy();
      }
    } catch (Exception e) {
      LOGGER.error("Exception caught when trying to shutdown the server->DAQ JMS connections:", e);
      e.printStackTrace(System.err);
    }
  }
}
 
Example 9
Source Project: Thunder   Source File: MQHierachy.java    License: Apache License 2.0 5 votes vote down vote up
private void initializeSingleConnectionFactory() throws Exception {
    boolean reconnectOnException = mqPropertyEntity.getBoolean(ThunderConstant.MQ_RECONNECT_ON_EXCEPTION_ATTRIBUTE_NAME);

    SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory();
    singleConnectionFactory.setReconnectOnException(reconnectOnException);

    connectionFactory = singleConnectionFactory;
}
 
Example 10
@Bean
@ConditionalOnMissingBean
public ConnectionFactory connectionFactory() {
    if (configurer != null) {
        return configurer.connectionFactory();
    }

    return new SingleConnectionFactory();
}
 
Example 11
Source Project: jadira   Source File: BatchedMessageListenerContainer.java    License: Apache License 2.0 5 votes vote down vote up
public Connection createConnection() throws JMSException {
    if (BatchedMessageListenerContainer.this.sharedConnectionEnabled()) {
        Connection sharedCon = BatchedMessageListenerContainer.this.getSharedConnection();
        return new SingleConnectionFactory(sharedCon).createConnection();
    } else {
        return BatchedMessageListenerContainer.this.createConnection();
    }
}
 
Example 12
Source Project: c2mon   Source File: AdminJmsConfig.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public SingleConnectionFactory adminSingleConnectionFactory() {
  return new SingleConnectionFactory(adminActiveMQConnectionFactory());
}
 
Example 13
Source Project: c2mon   Source File: ClientJmsConfig.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public SingleConnectionFactory clientSingleConnectionFactory() {
  return new SingleConnectionFactory(clientActiveMQConnectionFactory());
}
 
Example 14
@Bean
public SingleConnectionFactory heartbeatSingleConnectionFactory() {
  return new SingleConnectionFactory(heartbeatConnectionFactory());
}
 
Example 15
Source Project: c2mon   Source File: DaqJmsConfig.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public SingleConnectionFactory processOutConnectionFactory() {
  return new SingleConnectionFactory(daqOutActiveMQConnectionFactory());
}
 
Example 16
Source Project: c2mon   Source File: JmsConfig.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public SingleConnectionFactory singleConnectionFactory() {
  return new SingleConnectionFactory(activeMQConnectionFactory());
}
 
Example 17
Source Project: c2mon   Source File: JmsConfig.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public SingleConnectionFactory filterConnectionFactory() {
  return new SingleConnectionFactory(filterActiveMQConnectionFactory());
}
 
Example 18
Source Project: c2mon   Source File: JmsConfig.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public SingleConnectionFactory secondSingleConnectionFactory() {
  return new SingleConnectionFactory(secondActiveMQConnectionFactory());
}
 
Example 19
Source Project: citrus-simulator   Source File: SimulatorJmsAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectionFactory connectionFactory() {
    return new SingleConnectionFactory();
}
 
Example 20
Source Project: nifi   Source File: ConsumeJMS.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * <p>
 * Use provided clientId for non shared durable consumers, if not set
 * always a different value as defined in {@link AbstractJMSProcessor#setClientId(ProcessContext, SingleConnectionFactory)}.
 * </p>
 * See {@link Session#createDurableConsumer(javax.jms.Topic, String, String, boolean)},
 * in special following part: <i>An unshared durable subscription is
 * identified by a name specified by the client and by the client identifier,
 * which must be set. An application which subsequently wishes to create
 * a consumer on that unshared durable subscription must use the same
 * client identifier.</i>
 */
@Override
protected void setClientId(ProcessContext context, SingleConnectionFactory cachingFactory) {
    if (isDurableSubscriber(context) && !isShared(context)) {
        cachingFactory.setClientId(getClientId(context));
    } else {
        super.setClientId(context, cachingFactory);
    }
}
 
Example 21
Source Project: nifi   Source File: AbstractJMSProcessor.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Set clientId for JMS connections when <tt>clientId</tt> is not null.
 * It is overridden by {@code}ConsumeJMS{@code} when durable subscriptions
 * is configured on the processor.
 * @param context context.
 * @param connectionFactory the connection factory.
 * @since NIFI-6915
 */
protected void setClientId(ProcessContext context, final SingleConnectionFactory connectionFactory) {
    String clientId = getClientId(context);
    if (clientId != null) {
        clientId = clientId + "-" + clientIdCounter.getAndIncrement();
        connectionFactory.setClientId(clientId);
    }
}