當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。