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


Java ActiveMQQueue类代码示例

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


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

示例1: testJob

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testJob() throws Exception {
	ActiveMQQueue destinationInput = new ActiveMQQueue("input");
	ActiveMQQueue destinationOutput = new ActiveMQQueue("output");
	this.application.start(new String[] { "g:com.google.code.gson", destinationInput.getQueueName() });
	Page<Artifact, Artifact> output = (Page<Artifact, Artifact>) this.jmsTemplate
			.receiveAndConvert(destinationOutput);
	Assert.assertTrue(output.getKey().get() instanceof Artifact);
	Assert.assertNotNull(output.getKey().get().getProperties().get("timestamp"));
	Assert.assertEquals(output.getElements().size(), 209);
	Assert.assertTrue(output.getElements().get(0) instanceof Artifact);
	output = (Page<Artifact, Artifact>) this.jmsTemplate.receiveAndConvert(destinationOutput);
	Assert.assertTrue(output.getKey().get() instanceof Artifact);
	Assert.assertEquals(output.getElements().size(), 207);
	Assert.assertTrue(output.getElements().get(0) instanceof Artifact);
	this.jmsTemplate.setReceiveTimeout(100);
	Assert.assertNull(this.jmsTemplate.receive(destinationOutput));
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:20,代码来源:ApplicationTest.java

示例2: addQueueToBindingRegistry

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
@Override
public boolean addQueueToBindingRegistry(final String queueName, final String registryBinding) throws Exception {
   checkInitialised();

   checkBindings(registryBinding);

   ActiveMQQueue destination = queues.get(queueName);
   if (destination == null) {
      throw new IllegalArgumentException("Queue does not exist");
   }
   if (destination.getQueueName() == null) {
      throw new IllegalArgumentException(queueName + " is not a queue");
   }
   boolean added = bindToBindings(registryBinding, destination);
   if (added) {
      addToBindings(queueBindings, queueName, registryBinding);
      storage.addBindings(PersistedType.Queue, queueName, registryBinding);
   }
   return added;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:JMSServerManagerImpl.java

示例3: jobFactory

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
@Bean
public Supplier<Job> jobFactory(JmsTemplate jmsTemplate, Artifact jreArtifact,
		GraphDatabaseService graphDatabaseService) throws SettingsBuildingException {
	return () -> {
		ItemReader<Page<Artifact, Artifact>> reader = new Reader(jmsTemplate, new ActiveMQQueue(this.output));
		ItemProcessor<Page<Artifact, Artifact>, Result> processor = new Processor(new AnalysisRunner(this.timeout),
				jreArtifact, new File(this.lastModifiedCache), this.groupIdFilter);
		ItemWriter<Result> writer = new Writer(graphDatabaseService);
		Step step = this.stepBuilderFactory.get("analysis").<Page<Artifact, Artifact>, Result>chunk(1)
				.faultTolerant().skipPolicy(new LoggingAlwaysSkipItemSkipPolicy()).noRollback(Throwable.class)
				.reader(reader).processor(processor).writer(writer).build();
		return this.jobBuilderFactory.get("analysis").start(step).build();
	};
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:15,代码来源:Configuration.java

示例4: createJmsQueue

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
@POST
@Consumes("application/activemq.jms.queue+xml")
public Response createJmsQueue(@Context UriInfo uriInfo, Document document) {
   ActiveMQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\"");

   try {
      JMSQueueConfiguration queue = FileJMSConfiguration.parseQueueConfiguration(document.getDocumentElement());
      ActiveMQQueue activeMQQueue = ActiveMQDestination.createQueue(queue.getName());
      String queueName = activeMQQueue.getAddress();
      ClientSession session = manager.getSessionFactory().createSession(false, false, false);
      try {

         ClientSession.QueueQuery query = session.queueQuery(new SimpleString(queueName));
         if (!query.isExists()) {
            if (queue.getSelector() != null) {
               session.createQueue(queueName, queueName, queue.getSelector(), queue.isDurable());
            } else {
               session.createQueue(queueName, queueName, queue.isDurable());
            }

         } else {
            throw new WebApplicationException(Response.status(412).type("text/plain").entity("Queue already exists.").build());
         }
      } finally {
         try {
            session.close();
         } catch (Exception ignored) {
         }
      }
      URI uri = uriInfo.getRequestUriBuilder().path(queueName).build();
      return Response.created(uri).build();
   } catch (Exception e) {
      if (e instanceof WebApplicationException)
         throw (WebApplicationException) e;
      throw new WebApplicationException(e, Response.serverError().type("text/plain").entity("Failed to create queue.").build());
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:38,代码来源:QueueDestinationsResource.java

示例5: testLegacy2

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
/** This test will use an ArtemisConnectionFactory with clientProtocolManager=*/
@Test
public void testLegacy2() throws Exception {

   ConnectionFactoryConfiguration configuration = new ConnectionFactoryConfigurationImpl();
   configuration.setConnectorNames("legacy");
   configuration.setName("legacy");
   configuration.setProtocolManagerFactoryStr(HornetQClientProtocolManagerFactory.class.getName());
   embeddedJMS.getJMSServerManager().createConnectionFactory(false, configuration, "legacy");

   // WORKAROUND: the 2.0.0 broker introduced addressing change and the 2.2.0 broker added compatibility for old
   // client libraries relying on the legacy prefixes. The new client being used in this test needs prefix explicitly.
   Queue queue = new ActiveMQQueue("jms.queue.testQueue");

   ActiveMQConnectionFactory connectionFactory = (ActiveMQConnectionFactory) embeddedJMS.lookup("legacy");
   Connection connection = connectionFactory.createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(queue);

   TextMessage message = session.createTextMessage("Test");
   for (int i = 0; i < 5; i++) {
      message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), "duplicate");
      producer.send(message);
   }

   connection.start();
   MessageConsumer consumer = session.createConsumer(queue);
   TextMessage messageRec = (TextMessage) consumer.receive(5000);
   Assert.assertNotNull(messageRec);

   Assert.assertEquals("Test", messageRec.getText());
   Assert.assertNull(consumer.receiveNoWait());
   connection.close();
   connectionFactory.close();

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:37,代码来源:HornetQProtocolManagerTest.java

示例6: visitInputNode

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
@Override
public void visitInputNode(InputNode node) {
	this.input = new ActiveMQQueue(node.getName());
	this.readLimit = node.getReadLimit();
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:6,代码来源:WorkerPoolParser.java

示例7: visitQueueOutput

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
@Override
public void visitQueueOutput(QueueOutput node) {
	this.queue = new ActiveMQQueue(node.getName());
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:5,代码来源:WorkerPoolParser.java

示例8: start

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
public void start(String[] args) throws IOException, InterruptedException {
	if (args.length == 2) {
		SolrQuery query = new SolrQuery(args[0]);
		ActiveMQQueue queue = new ActiveMQQueue(args[1]);
		this.jmsTemplate.convertAndSend(queue, query);
	} else if (args.length != 0) {
		throw new IllegalArgumentException("must have 0 or two arguments: query queue");
	}
	// read properties
	PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
	propertiesFactoryBean.setLocation(new ClassPathResource("collector.properties"));
	propertiesFactoryBean.afterPropertiesSet();
	Properties properties = propertiesFactoryBean.getObject();
	// parse worker pools
	Map<String, WorkerPool> workerPools = properties.entrySet().stream()
			.collect(Collectors.toMap(entry -> entry.getKey().toString(),
					entry -> this.workerPoolsParser.parse(entry.getValue().toString())));
	// build jobs
	Map<Job, Integer> jobs = workerPools.entrySet().stream().collect(Collectors.toMap(entry -> {
		String name = entry.getKey();
		WorkerPool workerPool = entry.getValue();
		@SuppressWarnings("unchecked")
		Step step = this.stepBuilderFactory.get(name).chunk(1).faultTolerant()
				.skipPolicy(new LoggingAlwaysSkipItemSkipPolicy()).noRollback(Throwable.class)
				.reader(workerPool.getReader())
				.processor((ItemProcessor<? super Object, ? extends Object>) workerPool.getProcessor())
				.writer((ItemWriter<? super Object>) workerPool.getWriter()).build();
		return this.jobBuilderFactory.get(name).start(step).build();
	}, entry -> entry.getValue().getSize()));
	// launch jobs
	List<JobExecution> jobExecutions = jobs.entrySet().stream()
			.flatMap(entry -> IntStream.range(0, entry.getValue()).mapToObj(i -> {
				JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
				jobParametersBuilder.addString("id", entry.getKey().getName() + "-" + i, true);
				try {
					return this.jobLauncher.run(entry.getKey(), jobParametersBuilder.toJobParameters());
				} catch (JobExecutionAlreadyRunningException | JobRestartException
						| JobInstanceAlreadyCompleteException | JobParametersInvalidException exception) {
					throw new RuntimeException(exception);
				}
			})).collect(Collectors.toList());
	// wait for termination
	while (jobExecutions.stream().anyMatch(jobExecution -> jobExecution.getStatus().isRunning())) {
		Thread.sleep(1000);
	}
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:47,代码来源:Application.java

示例9: destinationInput

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
@Bean
public ActiveMQQueue destinationInput() {
	return new ActiveMQQueue("input");
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:5,代码来源:TestConfiguration.java

示例10: destinationOutput

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
@Bean
public ActiveMQQueue destinationOutput() {
	return new ActiveMQQueue("output");
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:5,代码来源:TestConfiguration.java

示例11: createQueue

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
protected Queue createQueue(String queueName) {
    return new ActiveMQQueue(queueName);
}
 
开发者ID:rh-messaging,项目名称:cli-java,代码行数:4,代码来源:AccConnectionManager.java

示例12: sendConsumeCore

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
private static void sendConsumeCore() throws JMSException {
   Connection connection = null;
   try {
      // Perform a lookup on the Connection Factory
      ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616");

      Queue queue = new ActiveMQQueue("exampleQueue");

      // Create a JMS Connection
      connection = cf.createConnection();

      // Create a JMS Session
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

      // Create a JMS Message Producer
      MessageProducer producer = session.createProducer(queue);

      // Create a Text Message
      TextMessage message = session.createTextMessage("This is a text message");

      // Send the Message
      producer.send(message);

      // Create a JMS Message Consumer
      MessageConsumer messageConsumer = session.createConsumer(queue);

      // Start the Connection
      connection.start();

      // Receive the message
      TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);

      if (messageReceived.getStringProperty("count") == null) {
         throw new RuntimeException(("missed property count"));
      }

      System.out.println("message = " + messageReceived.getText() + " property count (added by interceptor = " + messageReceived.getStringProperty("count") + ")");

   } finally {
      if (connection != null) {
         connection.close();
      }
   }

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:46,代码来源:BrokerPluginExample.java

示例13: createCoreQueue

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
protected Queue createCoreQueue(final String queueName) throws Exception {
   SimpleString address = SimpleString.toSimpleString(queueName);
   clientSession.createAddress(address, RoutingType.ANYCAST, false);
   return new ActiveMQQueue(queueName);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:6,代码来源:LargeMessageQueueAutoCreationTest.java

示例14: createQueue

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
protected Queue createQueue(final String queueName) throws Exception {
   SimpleString address = SimpleString.toSimpleString(queueName);
   clientSession.createAddress(address, RoutingType.ANYCAST, false);
   return new ActiveMQQueue(queueName);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:6,代码来源:QueueAutoCreationTest.java

示例15: testReferenceQueue

import org.apache.activemq.artemis.jms.client.ActiveMQQueue; //导入依赖的package包/类
@Test
public void testReferenceQueue() throws Exception {
   Reference queueRef = ((Referenceable) queue1).getReference();

   String factoryName = queueRef.getFactoryClassName();

   Class<?> factoryClass = Class.forName(factoryName);

   ObjectFactory factory = (ObjectFactory) factoryClass.newInstance();

   Object instance = factory.getObjectInstance(queueRef, null, null, null);

   ProxyAssertSupport.assertTrue(instance instanceof ActiveMQDestination);

   ActiveMQQueue queue2 = (ActiveMQQueue) instance;

   ProxyAssertSupport.assertEquals(queue1.getQueueName(), queue2.getQueueName());

   simpleSendReceive(cf, queue2);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:ReferenceableTest.java


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