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


Java JmsListenerEndpoint类代码示例

本文整理汇总了Java中org.springframework.jms.config.JmsListenerEndpoint的典型用法代码示例。如果您正苦于以下问题:Java JmsListenerEndpoint类的具体用法?Java JmsListenerEndpoint怎么用?Java JmsListenerEndpoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: replaceMethodJmsListenerEndpoint

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
private JmsListenerEndpoint replaceMethodJmsListenerEndpoint(MethodJmsListenerEndpoint original) {
  MethodJmsListenerEndpoint replacement = new TracingMethodJmsListenerEndpoint();

  replacement.setBean(original.getBean());
  replacement.setMethod(original.getMethod());
  replacement.setMostSpecificMethod(original.getMostSpecificMethod());
  MessageHandlerMethodFactory messageHandlerMethodFactory = registrar
      .getMessageHandlerMethodFactory();
  if (messageHandlerMethodFactory == null) {
    messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
  }
  replacement.setMessageHandlerMethodFactory(messageHandlerMethodFactory);
  replacement.setBeanFactory(beanFactory);
  replacement.setId(original.getId());
  replacement.setDestination(original.getDestination());
  replacement.setSelector(original.getSelector());
  replacement.setSubscription(original.getSubscription());
  replacement.setConcurrency(original.getConcurrency());

  return replacement;
}
 
开发者ID:opentracing-contrib,项目名称:java-jms,代码行数:22,代码来源:TracingJmsListenerEndpointRegistry.java

示例2: simpleMessageListener

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void simpleMessageListener() throws Exception {
	ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
			Config.class, SimpleMessageListenerTestBean.class);

	JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class);
	assertEquals("One container should have been registered", 1, factory.getListenerContainers().size());
	MessageListenerTestContainer container = factory.getListenerContainers().get(0);

	JmsListenerEndpoint endpoint = container.getEndpoint();
	assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass());
	MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint;
	assertEquals(SimpleMessageListenerTestBean.class, methodEndpoint.getBean().getClass());
	assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod());
	assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod());

	SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
	methodEndpoint.setupListenerContainer(listenerContainer);
	assertNotNull(listenerContainer.getMessageListener());

	assertTrue("Should have been started " + container, container.isStarted());
	context.close(); // Close and stop the listeners
	assertTrue("Should have been stopped " + container, container.isStopped());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:JmsListenerAnnotationBeanPostProcessorTests.java

示例3: metaAnnotationIsDiscovered

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void metaAnnotationIsDiscovered() throws Exception {
	ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
			Config.class, MetaAnnotationTestBean.class);

	try {
		JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class);
		assertEquals("one container should have been registered", 1, factory.getListenerContainers().size());

		JmsListenerEndpoint endpoint = factory.getListenerContainers().get(0).getEndpoint();
		assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass());
		MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint;
		assertEquals(MetaAnnotationTestBean.class, methodEndpoint.getBean().getClass());
		assertEquals(MetaAnnotationTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod());
		assertEquals(MetaAnnotationTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod());
		assertEquals("metaTestQueue", ((AbstractJmsListenerEndpoint) endpoint).getDestination());
	}
	finally {
		context.close();
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:JmsListenerAnnotationBeanPostProcessorTests.java

示例4: sendToAnnotationFoundOnProxy

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void sendToAnnotationFoundOnProxy() throws Exception {
	ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
			Config.class, ProxyConfig.class, ProxyTestBean.class);
	try {
		JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class);
		assertEquals("one container should have been registered", 1, factory.getListenerContainers().size());

		JmsListenerEndpoint endpoint = factory.getListenerContainers().get(0).getEndpoint();
		assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass());
		MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint;
		assertTrue(AopUtils.isJdkDynamicProxy(methodEndpoint.getBean()));
		assertTrue(methodEndpoint.getBean() instanceof SimpleService);
		assertEquals(SimpleService.class.getMethod("handleIt", String.class), methodEndpoint.getMethod());
		assertEquals(ProxyTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod());

		Method m = ReflectionUtils.findMethod(endpoint.getClass(), "getDefaultResponseDestination");
		ReflectionUtils.makeAccessible(m);
		Object destination = ReflectionUtils.invokeMethod(m, endpoint);
		assertEquals("SendTo annotation not found on proxy", "foobar", destination);
	}
	finally {
		context.close();
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:JmsListenerAnnotationBeanPostProcessorTests.java

示例5: testCustomConfiguration

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
/**
 * Test for {@link CustomBean} and an manually endpoint registered
 * with "myCustomEndpointId". The custom endpoint does not provide
 * any factory so it's registered with the default one
 */
public void testCustomConfiguration(ApplicationContext context) {
	JmsListenerContainerTestFactory defaultFactory =
			context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
	JmsListenerContainerTestFactory customFactory =
			context.getBean("customFactory", JmsListenerContainerTestFactory.class);
	assertEquals(1, defaultFactory.getListenerContainers().size());
	assertEquals(1, customFactory.getListenerContainers().size());
	JmsListenerEndpoint endpoint = defaultFactory.getListenerContainers().get(0).getEndpoint();
	assertEquals("Wrong endpoint type", SimpleJmsListenerEndpoint.class, endpoint.getClass());
	assertEquals("Wrong listener set in custom endpoint", context.getBean("simpleMessageListener"),
			((SimpleJmsListenerEndpoint) endpoint).getMessageListener());

	JmsListenerEndpointRegistry customRegistry =
			context.getBean("customRegistry", JmsListenerEndpointRegistry.class);
	assertEquals("Wrong number of containers in the registry", 2,
			customRegistry.getListenerContainerIds().size());
	assertEquals("Wrong number of containers in the registry", 2,
			customRegistry.getListenerContainers().size());
	assertNotNull("Container with custom id on the annotation should be found",
			customRegistry.getListenerContainer("listenerId"));
	assertNotNull("Container created with custom id should be found",
			customRegistry.getListenerContainer("myCustomEndpointId"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:AbstractJmsAnnotationDrivenTests.java

示例6: testJmsListenerContainerFactoryWithCustomSettings

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void testJmsListenerContainerFactoryWithCustomSettings() {
	load(EnableJmsConfiguration.class, "spring.jms.listener.autoStartup=false",
			"spring.jms.listener.acknowledgeMode=client",
			"spring.jms.listener.concurrency=2",
			"spring.jms.listener.maxConcurrency=10");
	JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean(
			"jmsListenerContainerFactory", JmsListenerContainerFactory.class);
	assertThat(jmsListenerContainerFactory.getClass())
			.isEqualTo(DefaultJmsListenerContainerFactory.class);
	DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory)
			.createListenerContainer(mock(JmsListenerEndpoint.class));
	assertThat(listenerContainer.isAutoStartup()).isFalse();
	assertThat(listenerContainer.getSessionAcknowledgeMode())
			.isEqualTo(Session.CLIENT_ACKNOWLEDGE);
	assertThat(listenerContainer.getConcurrentConsumers()).isEqualTo(2);
	assertThat(listenerContainer.getMaxConcurrentConsumers()).isEqualTo(10);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:JmsAutoConfigurationTests.java

示例7: testCustomContainerFactoryWithConfigurer

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void testCustomContainerFactoryWithConfigurer() {
	this.context = doLoad(
			new Class<?>[] { TestConfiguration9.class, EnableJmsConfiguration.class },
			"spring.jms.listener.autoStartup=false");
	assertThat(this.context.containsBean("jmsListenerContainerFactory")).isTrue();
	JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean(
			"customListenerContainerFactory", JmsListenerContainerFactory.class);
	assertThat(jmsListenerContainerFactory)
			.isInstanceOf(DefaultJmsListenerContainerFactory.class);
	DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory)
			.createListenerContainer(mock(JmsListenerEndpoint.class));
	assertThat(listenerContainer.getCacheLevel())
			.isEqualTo(DefaultMessageListenerContainer.CACHE_CONSUMER);
	assertThat(listenerContainer.isAutoStartup()).isFalse();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:JmsAutoConfigurationTests.java

示例8: testJmsListenerContainerFactoryWithCustomSettings

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void testJmsListenerContainerFactoryWithCustomSettings() {
	load(EnableJmsConfiguration.class, "spring.jms.listener.autoStartup=false",
			"spring.jms.listener.acknowledgeMode=client",
			"spring.jms.listener.concurrency=2",
			"spring.jms.listener.maxConcurrency=10");
	JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean(
			"jmsListenerContainerFactory", JmsListenerContainerFactory.class);
	assertEquals(DefaultJmsListenerContainerFactory.class,
			jmsListenerContainerFactory.getClass());
	DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory)
			.createListenerContainer(mock(JmsListenerEndpoint.class));
	assertEquals(false, listenerContainer.isAutoStartup());
	assertEquals(Session.CLIENT_ACKNOWLEDGE,
			listenerContainer.getSessionAcknowledgeMode());
	assertEquals(2, listenerContainer.getConcurrentConsumers());
	assertEquals(10, listenerContainer.getMaxConcurrentConsumers());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:19,代码来源:JmsAutoConfigurationTests.java

示例9: testDefaultContainerFactoryWithJtaTransactionManager

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void testDefaultContainerFactoryWithJtaTransactionManager() {
	this.context = createContext(TestConfiguration7.class,
			EnableJmsConfiguration.class);
	JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean(
			"jmsListenerContainerFactory", JmsListenerContainerFactory.class);
	assertEquals(DefaultJmsListenerContainerFactory.class,
			jmsListenerContainerFactory.getClass());
	DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory)
			.createListenerContainer(mock(JmsListenerEndpoint.class));
	assertFalse("wrong session transacted flag with JTA transactions",
			listenerContainer.isSessionTransacted());
	assertSame(this.context.getBean(JtaTransactionManager.class),
			new DirectFieldAccessor(listenerContainer)
					.getPropertyValue("transactionManager"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:JmsAutoConfigurationTests.java

示例10: registerListenerContainer

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Override
public void registerListenerContainer(JmsListenerEndpoint endpoint,
    JmsListenerContainerFactory<?> factory, boolean startImmediately) {
  if (endpoint instanceof MethodJmsListenerEndpoint) {
    endpoint = replaceMethodJmsListenerEndpoint((MethodJmsListenerEndpoint) endpoint);
  }
  super.registerListenerContainer(endpoint, factory, startImmediately);
}
 
开发者ID:opentracing-contrib,项目名称:java-jms,代码行数:9,代码来源:TracingJmsListenerEndpointRegistry.java

示例11: createListenerContainer

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的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

示例12: registerListenerContainer

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Override
public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory) {
    JmsListenerEndpoint jmsListenerEndpoint = endpoint;
    if (endpoint instanceof MethodJmsListenerEndpoint) {
        MethodJmsListenerEndpointAdapter methodEndpoint = new MethodJmsListenerEndpointAdapter(
                (MethodJmsListenerEndpoint) endpoint, messageHandlerMethodFactory);
        methodEndpoint.setBeanFactory(beanFactory);
        jmsListenerEndpoint = methodEndpoint;
    }
    super.registerListenerContainer(jmsListenerEndpoint, factory);
}
 
开发者ID:kinglcc,项目名称:spring-boot-jms,代码行数:12,代码来源:JmsListenerEndpointRegistryAdapter.java

示例13: testDefaultContainerFactoryWithJtaTransactionManager

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void testDefaultContainerFactoryWithJtaTransactionManager() {
	this.context = createContext(TestConfiguration7.class,
			EnableJmsConfiguration.class);
	JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean(
			"jmsListenerContainerFactory", JmsListenerContainerFactory.class);
	assertThat(jmsListenerContainerFactory.getClass())
			.isEqualTo(DefaultJmsListenerContainerFactory.class);
	DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory)
			.createListenerContainer(mock(JmsListenerEndpoint.class));
	assertThat(listenerContainer.isSessionTransacted()).isFalse();
	assertThat(new DirectFieldAccessor(listenerContainer)
			.getPropertyValue("transactionManager"))
					.isSameAs(this.context.getBean(JtaTransactionManager.class));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:JmsAutoConfigurationTests.java

示例14: testDefaultContainerFactoryNonJtaTransactionManager

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void testDefaultContainerFactoryNonJtaTransactionManager() {
	this.context = createContext(TestConfiguration8.class,
			EnableJmsConfiguration.class);
	JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean(
			"jmsListenerContainerFactory", JmsListenerContainerFactory.class);
	assertThat(jmsListenerContainerFactory.getClass())
			.isEqualTo(DefaultJmsListenerContainerFactory.class);
	DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory)
			.createListenerContainer(mock(JmsListenerEndpoint.class));
	assertThat(listenerContainer.isSessionTransacted()).isTrue();
	assertThat(new DirectFieldAccessor(listenerContainer)
			.getPropertyValue("transactionManager")).isNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:JmsAutoConfigurationTests.java

示例15: testDefaultContainerFactoryNoTransactionManager

import org.springframework.jms.config.JmsListenerEndpoint; //导入依赖的package包/类
@Test
public void testDefaultContainerFactoryNoTransactionManager() {
	this.context = createContext(EnableJmsConfiguration.class);
	JmsListenerContainerFactory<?> jmsListenerContainerFactory = this.context.getBean(
			"jmsListenerContainerFactory", JmsListenerContainerFactory.class);
	assertThat(jmsListenerContainerFactory.getClass())
			.isEqualTo(DefaultJmsListenerContainerFactory.class);
	DefaultMessageListenerContainer listenerContainer = ((DefaultJmsListenerContainerFactory) jmsListenerContainerFactory)
			.createListenerContainer(mock(JmsListenerEndpoint.class));
	assertThat(listenerContainer.isSessionTransacted()).isTrue();
	assertThat(new DirectFieldAccessor(listenerContainer)
			.getPropertyValue("transactionManager")).isNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:JmsAutoConfigurationTests.java


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