当前位置: 首页>>代码示例>>Java>>正文


Java DefaultMessageListenerContainer.setPubSubDomain方法代码示例

本文整理汇总了Java中org.springframework.jms.listener.DefaultMessageListenerContainer.setPubSubDomain方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMessageListenerContainer.setPubSubDomain方法的具体用法?Java DefaultMessageListenerContainer.setPubSubDomain怎么用?Java DefaultMessageListenerContainer.setPubSubDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jms.listener.DefaultMessageListenerContainer的用法示例。


在下文中一共展示了DefaultMessageListenerContainer.setPubSubDomain方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hornetQMessageListenerContainer

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public MessageListenerContainer hornetQMessageListenerContainer() {
	Map<String, Object> map = new HashMap<String, Object>();
       map.put(TransportConstants.HOST_PROP_NAME, hornetq_host);  
       map.put(TransportConstants.PORT_PROP_NAME, hornetq_port);
	TransportConfiguration transportConfiguration =new TransportConfiguration(
			NettyConnectorFactory.class.getName(), map);
	
	HornetQConnectionFactory hornetQConnectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(
			JMSFactoryType.CF, transportConfiguration);
	
	DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
	container.setConnectionFactory((ConnectionFactory) hornetQConnectionFactory);
	container.setDestination(HornetQJMSClient.createTopic(IMConstant.GATEWAY_USERREGISTER_TOPIC));
	container.setPubSubDomain(true);
	container.setPubSubNoLocal(true);
	container.setMessageListener(userRegisterListener);
	container.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
	return container;
}
 
开发者ID:projectsrepos,项目名称:jim,代码行数:21,代码来源:GatewayUserRegisterConfig.java

示例2: init

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
  
  final AnalyticServiceServer server = new AnalyticServiceServer(getViewProcessor(), getPositionMaster(), getPortfolioMaster(), getConfigSource());
  server.setUser(getUser());
  server.setViewName(getViewName());
  server.setProviderIdName(getProviderIdName());
  
  AnalyticServiceTradeProducer tradeProducer = new AnalyticServiceTradeProducer();
  
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
  container.setMessageListener(
      new JmsByteArrayMessageDispatcher(
          new ByteArrayFudgeMessageReceiver(tradeProducer)));
  container.setDestinationName(getListenTopicName());
  container.setPubSubDomain(false);
  container.setConnectionFactory(getListenJmsConnector().getConnectionFactory());
  
  JmsAnalyticsDistributor analyticsDistributor = new JmsAnalyticsDistributor(new DefaultJmsTopicNameResolver(getPositionSource()), OpenGammaFudgeContext.getInstance(), _listenJmsConnector);
  server.setAnalyticResultReceiver(analyticsDistributor);
  
  server.setTradeProducer(tradeProducer);
  repo.registerLifecycle(server);
  repo.registerLifecycle(container);
  
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:AnalyticServiceServerFactory.java

示例3: setUpClass

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@BeforeClass
public void setUpClass() {
  JmsConnector jmsConnector = ActiveMQTestUtils.createTestJmsConnector();
  
  _factory = new JmsSenderFactory(jmsConnector);
  _mdd = MarketDataDistributorTest.getTestDistributor(_factory);
  
  _collectingReceiver = new CollectingByteArrayMessageReceiver();
  JmsByteArrayMessageDispatcher messageDispatcher = new JmsByteArrayMessageDispatcher(_collectingReceiver);
  
  _container = new DefaultMessageListenerContainer();
  _container.setConnectionFactory(jmsConnector.getConnectionFactory());
  _container.setMessageListener(messageDispatcher);
  _container.setDestinationName(_mdd.getDistributionSpec().getJmsTopic());
  _container.setPubSubDomain(true);
  _container.afterPropertiesSet();
  _container.start();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:JmsSenderTest.java

示例4: createListenerContainer

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Override
public DefaultMessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint) {
    DefaultMessageListenerContainer instance = super.createListenerContainer(endpoint);
    instance.setClientId(resolveClientId(endpoint));
    if (endpoint instanceof AbstractJmsListenerEndpoint) {
        AbstractJmsListenerEndpoint jmsEndpoint = ((AbstractJmsListenerEndpoint) endpoint);
        DestinationType destinationType = DestinationType.asDestinationType(jmsEndpoint.getDestination());
        instance.setPubSubDomain(destinationType.isPubSubDomain());
        instance.setSubscriptionDurable(destinationType.isSubscriptionDurable());
        instance.setSubscriptionShared(destinationType.isSubscriptionShared());
    }
    endpoint.setupListenerContainer(instance);

    return instance;
}
 
开发者ID:kinglcc,项目名称:spring-boot-jms,代码行数:16,代码来源:DynamicJmsListenerContainerFactory.java

示例5: mqMessageReceiver

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
/**
 * 配置基于发布订阅模式的消息监听容器,用于接收MQ转发过来的消息
 *
 * @param topicName
 * @param messageListener
 * @return
 */
public MessageListenerContainer mqMessageReceiver(String topicName, MessageListener messageListener) {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setConnectionFactory(jmsConnectionFactory());
    container.setDestinationName(topicName);
    container.setPubSubDomain(true);
    container.setPubSubNoLocal(true);
    container.setMessageListener(messageListener);
    container.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
    return container;
}
 
开发者ID:projectsrepos,项目名称:jim,代码行数:18,代码来源:GenericMQConfig.java

示例6: init

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
  LastKnownValueStoreProvider lkvStoreProvider =
      CogdaFactoryUtil.constructLastKnownValueStoreProvider(
          getDataRedisServer(),
          getDataRedisPort(),
          getDataRedisPrefix(),
          false,
          s_logger);
  CogdaLiveDataServer liveDataServer = new CogdaLiveDataServer(lkvStoreProvider);
  if (getListenPort() != null) {
    liveDataServer.setPortNumber(getListenPort());
  }
  liveDataServer.registerMetrics(OpenGammaMetricRegistry.getSummaryInstance(), OpenGammaMetricRegistry.getDetailedInstance(), "CogdaLiveDataServer");
  
  CogdaLiveDataServerUpdateListener updateListener = new CogdaLiveDataServerUpdateListener(liveDataServer);
  
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
  container.setMessageListener(
      new JmsByteArrayMessageDispatcher(
          new ByteArrayFudgeMessageReceiver(updateListener)));
  container.setDestinationName(getListenTopicName());
  container.setPubSubDomain(true);
  container.setConnectionFactory(getListenJmsConnector().getConnectionFactory());
  
  CogdaLiveDataServerMBean mbean = new CogdaLiveDataServerMBean(liveDataServer);
  
  repo.registerLifecycle(liveDataServer);
  repo.registerLifecycle(container);
  repo.registerMBean(mbean);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:32,代码来源:CogdaLiveDataServerFactory.java

示例7: createListenerContainer

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Override
protected AbstractMessageListenerContainer createListenerContainer() throws Exception {
    // Use DefaultMessageListenerContainer as it supports reconnects (see CAMEL-3193)
    DefaultMessageListenerContainer answer = new DefaultJmsMessageListenerContainer(endpoint, endpoint.isAllowReplyManagerQuickStop());

    answer.setDestinationName("temporary");
    answer.setDestinationResolver(destResolver);
    answer.setAutoStartup(true);
    if (endpoint.getMaxMessagesPerTask() >= 0) {
        answer.setMaxMessagesPerTask(endpoint.getMaxMessagesPerTask());
    }
    answer.setIdleConsumerLimit(endpoint.getIdleConsumerLimit());
    answer.setIdleTaskExecutionLimit(endpoint.getIdleTaskExecutionLimit());
    answer.setMessageListener(this);
    answer.setPubSubDomain(false);
    answer.setSubscriptionDurable(false);
    answer.setConcurrentConsumers(endpoint.getReplyToConcurrentConsumers());
    if (endpoint.getReplyToMaxConcurrentConsumers() > 0) {
        answer.setMaxConcurrentConsumers(endpoint.getReplyToMaxConcurrentConsumers());
    }
    answer.setConnectionFactory(endpoint.getConnectionFactory());
    // we use CACHE_CONSUMER by default to cling to the consumer as long as we can, since we can only consume
    // msgs from the JMS Connection that created the temp destination in the first place
    if (endpoint.getReplyToCacheLevelName() != null) {
        if ("CACHE_NONE".equals(endpoint.getReplyToCacheLevelName())) {
            throw new IllegalArgumentException("ReplyToCacheLevelName cannot be CACHE_NONE when using temporary reply queues. The value must be either CACHE_CONSUMER, or CACHE_SESSION");
        }
        answer.setCacheLevelName(endpoint.getReplyToCacheLevelName());
    } else {
        answer.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
    }
    String clientId = endpoint.getClientId();
    if (clientId != null) {
        clientId += ".CamelReplyManager";
        answer.setClientId(clientId);
    }

    // we cannot do request-reply over JMS with transaction
    answer.setSessionTransacted(false);
    
    // other optional properties
    answer.setExceptionListener(new TemporaryReplyQueueExceptionListener(destResolver, endpoint.getExceptionListener()));

    if (endpoint.getErrorHandler() != null) {
        answer.setErrorHandler(endpoint.getErrorHandler());
    } else {
        answer.setErrorHandler(new DefaultSpringErrorHandler(endpoint.getCamelContext(), TemporaryQueueReplyManager.class, 
                                                             endpoint.getErrorHandlerLoggingLevel(), endpoint.isErrorHandlerLogStackTrace()));
    }
    if (endpoint.getReceiveTimeout() >= 0) {
        answer.setReceiveTimeout(endpoint.getReceiveTimeout());
    }
    if (endpoint.getRecoveryInterval() >= 0) {
        answer.setRecoveryInterval(endpoint.getRecoveryInterval());
    }
    if (endpoint.getTaskExecutor() != null) {
        if (log.isDebugEnabled()) {
            log.debug("Using custom TaskExecutor: {} on listener container: {}", endpoint.getTaskExecutor(), answer);
        }
        answer.setTaskExecutor(endpoint.getTaskExecutor());
    }

    // setup a bean name which is used by Spring JMS as the thread name
    // use the name of the request destination
    String name = "TemporaryQueueReplyManager[" + endpoint.getDestinationName() + "]";
    answer.setBeanName(name);

    if (answer.getConcurrentConsumers() > 1) {
        // log that we are using concurrent consumers
        log.info("Using {}-{} concurrent consumers on {}",
                new Object[]{answer.getConcurrentConsumers(), answer.getMaxConcurrentConsumers(), name});
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:75,代码来源:TemporaryQueueReplyManager.java

示例8: topicConduit

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Test(invocationCount = 5, successPercentage = 19)
public void topicConduit() throws Exception {
  String topicName = "JmsByteArrayTransportTest-topicConduit-" + System.getProperty("user.name") + "-" + System.currentTimeMillis();
  ConnectionFactory cf = ActiveMQTestUtils.createTestConnectionFactory();
  JmsTemplate jmsTemplate = new JmsTemplate();
  jmsTemplate.setConnectionFactory(cf);
  jmsTemplate.setPubSubDomain(true);
  
  JmsByteArrayMessageSender messageSender = new JmsByteArrayMessageSender(topicName, jmsTemplate);
  CollectingByteArrayMessageReceiver collectingReceiver = new CollectingByteArrayMessageReceiver();
  JmsByteArrayMessageDispatcher messageDispatcher = new JmsByteArrayMessageDispatcher(collectingReceiver);
  
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
  container.setConnectionFactory(cf);
  container.setMessageListener(messageDispatcher);
  container.setDestinationName(topicName);
  container.setPubSubDomain(true);
  container.afterPropertiesSet();
  container.start();

  Random random = new Random();
  byte[] randomBytes = new byte[1024];
  random.nextBytes(randomBytes);
  
  while(!container.isRunning()) {
    Thread.sleep(10l);
  }
  //TODO: this is a hack.  The context doesn't seem to have always set up the consumer completely yet
  Thread.sleep(500l);
  
  messageSender.send(randomBytes);
  long startTime = System.currentTimeMillis();
  while(collectingReceiver.getMessages().isEmpty()) {
    Thread.sleep(10l);
    if ((System.currentTimeMillis() - startTime) > TIMEOUT) {
      fail("Did not receive a message in " + (TIMEOUT / 1000) + " seconds.");
    }
  }
  s_logger.debug ("topicConduit message received {}ms before timeout limit", TIMEOUT - (System.currentTimeMillis () - startTime));
  assertEquals(1, collectingReceiver.getMessages().size());
  byte[] receivedBytes = collectingReceiver.getMessages().get(0);
  assertEquals(randomBytes.length, receivedBytes.length);
  for(int i = 0; i < randomBytes.length; i++) {
    assertEquals(randomBytes[i], receivedBytes[i]);
  }
  
  container.stop();
  container.destroy();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:50,代码来源:JmsByteArrayTransportTest.java

示例9: requestConduit

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Test(invocationCount = 5, successPercentage = 19)
public void requestConduit() throws Exception {
  String topicName = "JmsByteArrayTransportTest-requestConduit-" + System.getProperty("user.name") + "-" + System.currentTimeMillis();
  ConnectionFactory cf = ActiveMQTestUtils.createTestConnectionFactory();
  JmsTemplate jmsTemplate = new JmsTemplate();
  jmsTemplate.setConnectionFactory(cf);
  jmsTemplate.setPubSubDomain(true);
  jmsTemplate.setReceiveTimeout(5000l);

  final Random random = new Random();
  final byte[] responseBytes = new byte[512];
  random.nextBytes(responseBytes);
  
  JmsByteArrayRequestSender requestSender = new JmsByteArrayRequestSender(topicName, jmsTemplate);
  JmsByteArrayRequestDispatcher requestDispatcher = new JmsByteArrayRequestDispatcher(new ByteArrayRequestReceiver() {
    @Override
    public byte[] requestReceived(byte[] message) {
      return responseBytes;
    }
  });
  
  DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
  container.setConnectionFactory(cf);
  container.setMessageListener(requestDispatcher);
  container.setDestinationName(topicName);
  container.setPubSubDomain(true);
  container.afterPropertiesSet();
  container.start();

  byte[] randomBytes = new byte[1024];
  random.nextBytes(randomBytes);
  
  while(!container.isRunning()) {
    Thread.sleep(10l);
  }
  
  CollectingByteArrayMessageReceiver collectingReceiver = new CollectingByteArrayMessageReceiver();
  requestSender.sendRequest(randomBytes, collectingReceiver);
  long startTime = System.currentTimeMillis();
  while(collectingReceiver.getMessages().isEmpty()) {
    Thread.sleep(10l);
    if ((System.currentTimeMillis() - startTime) > TIMEOUT) {
      fail("Did not receive a response in " + (TIMEOUT / 1000) + " seconds.");
    }
  }
  s_logger.debug ("requestConduit message received {}ms before timeout limit", TIMEOUT - (System.currentTimeMillis () - startTime));
  assertEquals(1, collectingReceiver.getMessages().size());
  byte[] receivedBytes = collectingReceiver.getMessages().get(0);
  assertEquals(responseBytes.length, receivedBytes.length);
  for(int i = 0; i < responseBytes.length; i++) {
    assertEquals(responseBytes[i], receivedBytes[i]);
  }
  
  container.stop();
  container.destroy();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:57,代码来源:JmsByteArrayTransportTest.java

示例10: doCreate

import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
/**
 * Creates a container to receive JMS messages.
 * 
 * @param connectionFactory  the JMS connection factory, not null
 * @param destinationName  the queue or topic name, not null
 * @param isPubSub true if this is for a topic
 * @param listener  the listener, not null
 * @return the container, not null
 */
protected DefaultMessageListenerContainer doCreate(ConnectionFactory connectionFactory, String destinationName, boolean isPubSub, Object listener) {
  DefaultMessageListenerContainer jmsContainer = new DefaultMessageListenerContainer();
  jmsContainer.setConnectionFactory(connectionFactory);
  jmsContainer.setDestinationName(destinationName);
  jmsContainer.setPubSubDomain(isPubSub);
  jmsContainer.setMessageListener(listener);
  return jmsContainer;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:18,代码来源:AbstractSpringContainerFactory.java


注:本文中的org.springframework.jms.listener.DefaultMessageListenerContainer.setPubSubDomain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。