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


Java BytesMessage.setIntProperty方法代码示例

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


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

示例1: sendMessagesToBroker

import javax.jms.BytesMessage; //导入方法依赖的package包/类
protected void sendMessagesToBroker(Connection connection, int count, AtomicInteger sequence) throws Exception {
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Queue queue = session.createQueue(getQueueName());
   MessageProducer producer = session.createProducer(queue);

   byte[] buffer = new byte[MESSAGE_SIZE];
   for (count = 0; count < MESSAGE_SIZE; count++) {
      String s = String.valueOf(count % 10);
      Character c = s.charAt(0);
      int value = c.charValue();
      buffer[count] = (byte) value;
   }

   LOG.debug("Sending {} messages to destination: {}", MESSAGE_COUNT, queue);
   for (int i = 1; i <= MESSAGE_COUNT; i++) {
      BytesMessage message = session.createBytesMessage();
      message.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
      message.setStringProperty("JMSXGroupID", JMSX_GROUP_ID);
      message.setIntProperty("JMSXGroupSeq", sequence.incrementAndGet());
      message.writeBytes(buffer);
      producer.send(message);
   }

   session.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:JMSMessageGroupsTest.java

示例2: createByteMsgs

import javax.jms.BytesMessage; //导入方法依赖的package包/类
private void createByteMsgs(int numMessages) throws Exception
{
  BytesMessage message = testMeta.session.createBytesMessage();
  for (int i = 0; i < numMessages; i++) {
    message.writeBytes(("Message: " + i).getBytes());
    message.setIntProperty("counter", i);
    message.setJMSCorrelationID("MyCorrelationID");
    message.setJMSReplyTo(new ActiveMQQueue("MyReplyTo"));
    message.setJMSType("MyType");
    message.setJMSPriority(5);
    testMeta.producer.send(message);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:14,代码来源:JMSObjectInputOperatorTest.java

示例3: testSubscribeWithMessageSentWithProperties

import javax.jms.BytesMessage; //导入方法依赖的package包/类
@Test
public void testSubscribeWithMessageSentWithProperties() throws Exception {
   conn.connect(defUser, defPass);
   subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);

   MessageProducer producer = session.createProducer(queue);
   BytesMessage message = session.createBytesMessage();
   message.setStringProperty("S", "value");
   message.setBooleanProperty("n", false);
   message.setByteProperty("byte", (byte) 9);
   message.setDoubleProperty("d", 2.0);
   message.setFloatProperty("f", (float) 6.0);
   message.setIntProperty("i", 10);
   message.setLongProperty("l", 121);
   message.setShortProperty("s", (short) 12);
   message.writeBytes("Hello World".getBytes(StandardCharsets.UTF_8));
   producer.send(message);

   ClientStompFrame frame = conn.receiveFrame(10000);
   Assert.assertNotNull(frame);
   Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand());
   Assert.assertEquals("value", frame.getHeader("S"));
   Assert.assertEquals("false", frame.getHeader("n"));
   Assert.assertEquals("9", frame.getHeader("byte"));
   Assert.assertEquals("2.0", frame.getHeader("d"));
   Assert.assertEquals("6.0", frame.getHeader("f"));
   Assert.assertEquals("10", frame.getHeader("i"));
   Assert.assertEquals("121", frame.getHeader("l"));
   Assert.assertEquals("12", frame.getHeader("s"));
   Assert.assertEquals("Hello World", frame.getBody());

   conn.disconnect();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:34,代码来源:StompTest.java

示例4: testSubscribeWithMessageSentWithProperties

import javax.jms.BytesMessage; //导入方法依赖的package包/类
@Test
public void testSubscribeWithMessageSentWithProperties() throws Exception {
   conn.connect(defUser, defPass);

   subscribe(conn, "sub1", Stomp.Headers.Subscribe.AckModeValues.AUTO);

   MessageProducer producer = session.createProducer(queue);
   BytesMessage message = session.createBytesMessage();
   message.setStringProperty("S", "value");
   message.setBooleanProperty("n", false);
   message.setByteProperty("byte", (byte) 9);
   message.setDoubleProperty("d", 2.0);
   message.setFloatProperty("f", (float) 6.0);
   message.setIntProperty("i", 10);
   message.setLongProperty("l", 121);
   message.setShortProperty("s", (short) 12);
   message.writeBytes("Hello World".getBytes(StandardCharsets.UTF_8));
   producer.send(message);

   ClientStompFrame frame = conn.receiveFrame();
   Assert.assertNotNull(frame);

   Assert.assertTrue(frame.getHeader("S") != null);
   Assert.assertTrue(frame.getHeader("n") != null);
   Assert.assertTrue(frame.getHeader("byte") != null);
   Assert.assertTrue(frame.getHeader("d") != null);
   Assert.assertTrue(frame.getHeader("f") != null);
   Assert.assertTrue(frame.getHeader("i") != null);
   Assert.assertTrue(frame.getHeader("l") != null);
   Assert.assertTrue(frame.getHeader("s") != null);
   Assert.assertEquals("Hello World", frame.getBody());

   conn.disconnect();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:35,代码来源:StompV11Test.java

示例5: testTmpQueueWorksUnderLoad

import javax.jms.BytesMessage; //导入方法依赖的package包/类
/**
 * Test temp queue works under load
 *
 * @throws JMSException
 */
@Test
public void testTmpQueueWorksUnderLoad() throws JMSException {
   int count = 500;
   int dataSize = 1024;

   ArrayList<BytesMessage> list = new ArrayList<>(count);
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Queue queue = session.createTemporaryQueue();
   MessageProducer producer = session.createProducer(queue);
   producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

   byte[] data = new byte[dataSize];
   for (int i = 0; i < count; i++) {
      BytesMessage message = session.createBytesMessage();
      message.writeBytes(data);
      message.setIntProperty("c", i);
      producer.send(message);
      list.add(message);
   }

   connection.start();
   MessageConsumer consumer = session.createConsumer(queue);
   for (int i = 0; i < count; i++) {
      Message message2 = consumer.receive(2000);
      Assert.assertTrue(message2 != null);
      Assert.assertEquals(i, message2.getIntProperty("c"));
      Assert.assertTrue(message2.equals(list.get(i)));
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:35,代码来源:JmsTempDestinationTest.java

示例6: testBytesMessageSendReceive

import javax.jms.BytesMessage; //导入方法依赖的package包/类
private void testBytesMessageSendReceive(Connection producerConnection, Connection consumerConnection) throws Throwable {
   long time = System.currentTimeMillis();

   Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Queue queue = session.createQueue(getQueueName());

   byte[] bytes = new byte[0xf + 1];
   for (int i = 0; i <= 0xf; i++) {
      bytes[i] = (byte) i;
   }

   MessageProducer producer = session.createProducer(queue);
   for (int i = 0; i < NUM_MESSAGES; i++) {
      System.out.println("Sending " + i);
      BytesMessage message = session.createBytesMessage();

      message.writeBytes(bytes);
      message.setIntProperty("count", i);
      producer.send(message);
   }

   Session sessionConsumer = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Queue consumerQueue = sessionConsumer.createQueue(getQueueName());
   final MessageConsumer consumer = sessionConsumer.createConsumer(consumerQueue);

   for (int i = 0; i < NUM_MESSAGES; i++) {
      BytesMessage m = (BytesMessage) consumer.receive(5000);
      Assert.assertNotNull("Could not receive message count=" + i + " on consumer", m);

      m.reset();

      long size = m.getBodyLength();
      byte[] bytesReceived = new byte[(int) size];
      m.readBytes(bytesReceived);

      System.out.println("Received " + ByteUtil.bytesToHex(bytesReceived, 1) + " count - " + m.getIntProperty("count"));

      Assert.assertArrayEquals(bytes, bytesReceived);
   }

   long taken = (System.currentTimeMillis() - time) / 1000;
   System.out.println("taken = " + taken);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:44,代码来源:JMSMessageTypesTest.java


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